Skip to content

Instantly share code, notes, and snippets.

@altwitt
Created July 27, 2019 15:01
Show Gist options
  • Save altwitt/04f83f22e204bba78a034e26cc5b1c05 to your computer and use it in GitHub Desktop.
Save altwitt/04f83f22e204bba78a034e26cc5b1c05 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias -- -="cd -"
alias c='clear'
# Shortcuts
alias drop="cd ~/Dropbox;ls"
alias dl="cd ~/Downloads:ls"
alias docs="cd ~/Documents;ls"
alias dt="cd ~/Desktop;ls"
alias w="cd ~/Work;ls"
alias dev="cd ~/Work/dev;ls"
alias code="cd ~/Work/code;ls"
alias python='python3'
alias weather='curl wttr.in memphis'
alias f='open .'
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
# Disable Spotlight
alias spotoff="sudo mdutil -a -i off"
# Enable Spotlight
alias spoton="sudo mdutil -a -i on"
alias mute="osascript -e 'set volume output volume 0'"
alias loud="osascript -e 'set volume output volume 100'"
# Kill all the tabs in Chrome to free up memory
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
# Lock the screen (when going AFK)
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
# Reload the shell (i.e. invoke as a login shell)
alias reload="exec ${SHELL} -l"
alias hosts='sudo $EDITOR /etc/hosts' # yes I occasionally 127.0.0.1 twitter.com ;)
alias fix_stty='stty sane'
alias DT='tee ~/Desktop/terminalOut.txt' # DT: Pipe content to file on MacOS Desktop
# File size
alias df="df -h"
# Cleaning
# Empty the Trash on all mounted volumes and the main HDD.
# Also, clear Apple’s System Logs to improve shell startup speed.
# Finally, clear download history from quarantine. https://mths.be/bum
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
alias cleanupLS="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
# Recursively delete `.DS_Store` files
alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete"
alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections
# time to upgrade `ls`
# use coreutils `ls` if possible…
hash gls >/dev/null 2>&1 || alias gls="ls"
# always use color, even when piping (to awk,grep,etc)
if gls --color > /dev/null 2>&1; then colorflag="--color"; else colorflag="-G"; fi;
export CLICOLOR_FORCE=1
# ls options: A = include hidden (but not . or ..), F = put `/` after folders, h = byte unit suffixes
alias ls='gls -AFh ${colorflag} --group-directories-first'
alias lsd='ls -l | grep "^d"' # only directories
# `la` defined in .functions
###
# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'
# Away
alias s='pmset displaysleepnow'
###
alias bye='sudo shutdown -h now'
alias restart='sudo shutdown -r now'
alias diskspace_report="df -P -kHl"
# File size
alias fs="stat -f \"%z bytes\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment