From 8a508d982b7d938f824b441ed860fd2cd54b8224 Mon Sep 17 00:00:00 2001 From: Tim Triemstra Date: Mon, 22 Apr 2024 12:40:11 -0700 Subject: [PATCH] Fixing functions and aliases for Linux --- Linux/dot-aliases.sh | 81 ++++++++++++++++++++++++++++++ Linux/dot-functions.sh | 69 ++++++------------------- Linux/dotfiles.sh | 3 +- dotfiles.xcodeproj/project.pbxproj | 6 ++- 4 files changed, 103 insertions(+), 56 deletions(-) create mode 100755 Linux/dot-aliases.sh diff --git a/Linux/dot-aliases.sh b/Linux/dot-aliases.sh new file mode 100755 index 0000000..ba4bcf6 --- /dev/null +++ b/Linux/dot-aliases.sh @@ -0,0 +1,81 @@ +# source this file into .zshrc + +if [[ -v LOADED_ALIAS ]]; then return; fi +LOADED_ALIAS=true + + +# =========================================== +# Aliases + +# ... Turn off the Quarantine Bit for all files in local folder +alias qbit="xattr -d com.apple.quarantine ./*" + +# ... Eject a volume (type the volume name after) +alias eject="hdiutil detach -verbose -force /Volumes/" + +# ... Touch the time and date recursively for all files in current folder +alias touchall="find . -exec touch {} \;" + +# ... Tell Time Machine to use higher CPU priority until reboot +alias time-machine-fast="sudo sysctl debug.lowpri_throttle_enabled=0" + +# launch the iOS Simulator app from the command line +# you can then type "simulator help" or "simulator list" to see more info +alias simulator="xcrun simctl" + +# Recursively remove .DS_Store files +alias cleanupds="find . -type f -name '*.DS_Store' -ls -delete" + +# Easier navigation: .., ..., ~ and - +alias ..="cd .." +alias cd..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." +alias .....="cd ../../../.." + +# alias reload!='. ~/.zshrc' + +# mv, rm, cp +alias mv='mv -v' +alias rm='rm -i -v' +alias cp='cp -v' + +# Use the eza command by default, if installed (better ls) +if ! command -v eza &> /dev/null +then + echo "Tool \`eza\` not found. For a better \`ls\` run: brew install eza" + # Use 'll' to suppress the "show all" flag when listing files + alias ll='ls -oFGT' + # Use 'lla' to enable "show all" for hidden files beginning with a period + alias lla='ls -oAFGT' + # Use 'llx' to see the most info, including extended attributes + alias llx='ls -o@AFGT' + # Use 'llt' to see the files sorted by modification time + alias llt='ls -otAFGT' + # Make standard 'ls' look prettier, with colors and sorting + # alias ls='ls -FG' +else + echo "Aliasing \`ll\` and other \`ls\` commands to use \`eza\`" + + alias ll='eza --long --sort=Name --git --git-repos -I "Icon?" --group-directories-first --no-quotes --no-permissions --no-user' + alias lla='eza -a --long --sort=Name --git -I "Icon?" -I ".DS_Store" --group-directories-first' + alias llx='eza -a --long --sort=Name --git -I "Icon?" -I ".DS_Store" --group-directories-first -@ -Z' + alias llt='eza --tree' +fi + + +# Git can sometimes create locked files in the .git folder, which then +# blocks things like compress tasks, or copying files. Run "unlock" to +# unlock all files in the current folder (and recursively) +alias showlocks="find . -flags +uchg" + +alias unlock="find . -flags +uchg -exec chflags nouchg {} \;" + +# ... echo $SHELL tells you the default shell, this command +# instead tells you which shell you are presently inside +alias shell-now='ps -p $$' + +# original color-coded lsl command: alias lsl='ls -loFGT' +# sorts folders at the top: ls -la | grep "^d" && ls -la | grep -v "^d" +# NOTE: if you sort you lose the LS coloring in the output (sad face) + diff --git a/Linux/dot-functions.sh b/Linux/dot-functions.sh index 10e21c8..c0c21dd 100755 --- a/Linux/dot-functions.sh +++ b/Linux/dot-functions.sh @@ -1,68 +1,31 @@ -# source this file into .zshrc +#!/bin/zsh + +if [[ -v LOADED_FUNCTIONS ]]; then return; fi +LOADED_FUNCTIONS=true + # Functions to make output attractive when running the script -# # NOTE: some characters in parameters will not work, e.g. "!" -# + # `message` and `error` take two string parameters message () { printf "\r [\033[00;32m $1\033[0m ] $2\n" } error () { printf "\r\033[00;31m ** $1\033[0m - \033[00;31m$2 \033[0m \n" } +alert () { printf "\r\033[00;35m >> $1\033[0m $2\n" } +bullet () { printf "\r\033[00;36m ==\033[0m $1 $2\n" } -# `alert` and `bullet` take one parameter -alert () { printf "\r\033[00;35m >> $1\033[0m \n" } -bullet () { printf "\r\033[00;36m ==\033[0m $1\n" } - - -# Function to find all files recursively under current folder +# ... Find all files recursively under current folder findall () { find ./ -name $1 -print 2> /dev/null } -# Function to create a new directory and enter it +# ... Create a new directory and enter it md() { - mkdir -p "$@" && cd "$@" + mkdir -p "$@" && cd "$@" } -# =========================================== -# Aliases - -# Easier navigation: .., ..., ~ and - -alias ..="cd .." -alias cd..="cd .." -alias ...="cd ../.." -alias ....="cd ../../.." -alias .....="cd ../../../.." - -alias reload!='. ~/.zshrc' - -# mv, rm, cp -alias mv='mv -v' -alias rm='rm -i -v' -alias cp='cp -v' - -# ... Make 'ls' look a lot prettier -alias ls='ls -FG' -alias lsl='ls -loFGT' -alias lsla='ls -loAFGT' - -# ... echo $SHELL tells you the default shell, this command -# instead tells you which shell you are presently inside -alias shell-now='ps -p $$' - -# original color-coded lsl command: alias lsl='ls -loFGT' -# sorts folders at the top: ls -la | grep "^d" && ls -la | grep -v "^d" -# NOTE: if you sort you lose the LS coloring in the output (sad face) - - -# ... Turn off the Quarantine Bit for all files in local folder -alias qbit="xattr -d com.apple.quarantine ./*" - -# ... Eject a volume (type the volume name after) -alias eject="hdiutil detach -verbose -force /Volumes/" - -# ... Touch the time and date recursively for all files in current folder -alias touchall="find . -exec touch {} \;" - -# ... Tell Time Machine to use higher CPU priority until reboot -alias time-machine-fast="sudo sysctl debug.lowpri_throttle_enabled=0" +# Delete Xcode derived data +xcode-clean() { + echo "Deleting all Xcode derived data..." + rm -rdf ~/Library/Developer/Xcode/DerivedData/* +} diff --git a/Linux/dotfiles.sh b/Linux/dotfiles.sh index ad43fd5..558c84c 100755 --- a/Linux/dotfiles.sh +++ b/Linux/dotfiles.sh @@ -16,11 +16,12 @@ cp $DOTFILES_ROOT/Linux/dot-zshenv.sh $HOME/.zshenv cp $DOTFILES_ROOT/Linux/dot-aliases.sh $HOME/.aliases cp $DOTFILES_ROOT/Linux/dot-functions.sh $HOME/.functions -# Register gitignore and other git stuff +# Copy over tool and app settings cp $DOTFILES_ROOT/Config/dot-gitconfig $HOME/.gitconfig cp $DOTFILES_ROOT/Config/dot-gitignore $HOME/.gitignore cp $DOTFILES_ROOT/Config/dot-vimrc $HOME/.vimrc +# Register gitignore and other git stuff git config --global core.excludesfile ~/.gitignore diff --git a/dotfiles.xcodeproj/project.pbxproj b/dotfiles.xcodeproj/project.pbxproj index 6d1065f..21a93a7 100644 --- a/dotfiles.xcodeproj/project.pbxproj +++ b/dotfiles.xcodeproj/project.pbxproj @@ -35,10 +35,11 @@ BABDAC482BC1ED2100DA5858 /* index.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = index.md; sourceTree = ""; }; BABDAC492BC1ED2100DA5858 /* overview.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = overview.md; sourceTree = ""; }; BABDAC4A2BC1ED2100DA5858 /* todo.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = todo.md; sourceTree = ""; }; - BABDAC4C2BC1ED4700DA5858 /* dot-functions.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-functions.sh"; sourceTree = ""; }; BABDAC4D2BC1ED4700DA5858 /* dot-zshenv.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-zshenv.sh"; sourceTree = ""; }; BABDAC4E2BC1ED4700DA5858 /* dotfiles.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = dotfiles.sh; sourceTree = ""; }; BABDAC4F2BC1ED4700DA5858 /* dot-zshrc.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-zshrc.sh"; sourceTree = ""; }; + BAD8D5C82BD6F41400E0077F /* dot-aliases.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-aliases.sh"; sourceTree = ""; }; + BAF585262BD6F45100A2E7F1 /* dot-functions.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dot-functions.sh"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ @@ -114,7 +115,8 @@ BABDAC4B2BC1ED3C00DA5858 /* Linux */ = { isa = PBXGroup; children = ( - BABDAC4C2BC1ED4700DA5858 /* dot-functions.sh */, + BAF585262BD6F45100A2E7F1 /* dot-functions.sh */, + BAD8D5C82BD6F41400E0077F /* dot-aliases.sh */, BABDAC4D2BC1ED4700DA5858 /* dot-zshenv.sh */, BABDAC4F2BC1ED4700DA5858 /* dot-zshrc.sh */, BABDAC4E2BC1ED4700DA5858 /* dotfiles.sh */,