From e4d9827097727c7b9ef32ebcae5a3349661e2a42 Mon Sep 17 00:00:00 2001 From: Alec Rust Date: Sun, 28 Jan 2024 15:50:19 +0000 Subject: [PATCH] Tidy aliases --- dotfiles/.aliases | 59 ++++++++++++++++++++--------------------------- scripts/brew.sh | 2 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/dotfiles/.aliases b/dotfiles/.aliases index 2986eac..35bc588 100755 --- a/dotfiles/.aliases +++ b/dotfiles/.aliases @@ -3,16 +3,20 @@ # Enable aliases to be sudo’ed alias sudo='sudo ' -# Shortcuts +# Directory shortcuts +alias p="cd ~/projects" alias dl="cd ~/Downloads" alias dt="cd ~/Desktop" -alias p="cd ~/projects" -alias h="history" -alias j="jobs" + +# Shorten common commands alias e="exit" +alias h="history" alias hh="hstr" alias ytd="yt-dlp" +# Use latest curl (only when running interactively) +alias curl='/opt/homebrew/opt/curl/bin/curl' + # lsd (ls replacement) alias ls='lsd' alias l='ls -l' @@ -29,16 +33,27 @@ alias top="btm" # Reload the shell alias reload="source ~/.zshrc" -# Open iOS Simulator -alias ios-simulator="open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app" +# List all PATH entries +alias path='echo -e ${PATH//:/\\n}' + +# Get current month number +alias month='date +%m' + +# Get external IP address +alias ip="dig +short myip.opendns.com @resolver1.opendns.com" + +# Get internal IP address (depends on network interface, see `ifactive`) +alias localip="ipconfig getifaddr en5" + +# List all IPv4 and IPv6 addresses associated with all network interfaces on the system +alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" + +# Show active network interfaces +alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'" # Run Rails tests with bundle exec alias bert="bundle exec rails test" -# Start/stop Redis -alias redis-start="(redis-server &)" -alias redis-stop="(redis-cli shutdown)" - # More memorable Git branch cleanup alias git-clean-remote-branches="gfa" alias git-clean-local-branches="gbda" @@ -52,9 +67,6 @@ alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' -# Get current month number -alias month='date +%m' - # Update Zsh plugins and mise runtimes alias update-shell="antidote update; mise upgrade; mise prune" @@ -73,14 +85,6 @@ alias update-gems='gem update --system; gem update; gem cleanup' # Brave alias brave='/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser' -# IP addresses -alias ip="dig +short myip.opendns.com @resolver1.opendns.com" -alias localip="ipconfig getifaddr en0" -alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" - -# Show active network interfaces -alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'" - # Flush Directory Service cache alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder" @@ -96,11 +100,6 @@ command -v md5sum > /dev/null || alias md5sum="md5" # macOS has no `sha1sum`, so use `shasum` as a fallback command -v sha1sum > /dev/null || alias sha1sum="shasum" -# JavaScriptCore REPL -jscbin="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"; -[ -e "${jscbin}" ] && alias jsc="${jscbin}"; -unset jscbin; - # Trim new lines and copy to clipboard alias c="tr -d '\n' | pbcopy" @@ -135,11 +134,3 @@ alias plistbuddy="/usr/libexec/PlistBuddy" # For example, to list all directories that contain a certain file: # find . -name .gitattributes | map dirname alias map="xargs -n1" - -# One of @janmoesen’s ProTip™s -for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do - alias "${method}"="lwp-request -m '${method}'" -done - -# List all PATH entries -alias path='echo -e ${PATH//:/\\n}' diff --git a/scripts/brew.sh b/scripts/brew.sh index 7252ae4..87258cd 100755 --- a/scripts/brew.sh +++ b/scripts/brew.sh @@ -8,8 +8,8 @@ brew upgrade # Core macOS utilities brew install coreutils -brew install moreutils brew install findutils +brew install moreutils brew install openssh brew install gnu-sed brew install gnu-tar