Skip to content

Commit

Permalink
Tidy aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecRust committed Jan 28, 2024
1 parent 3f63379 commit e4d9827
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 35 deletions.
59 changes: 25 additions & 34 deletions dotfiles/.aliases
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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"
Expand All @@ -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"

Expand All @@ -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"

Expand All @@ -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"

Expand Down Expand Up @@ -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}'
2 changes: 1 addition & 1 deletion scripts/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4d9827

Please sign in to comment.