Useful Shell Functions/Aliases

These are some shell (specifically zsh) functions and aliases I use pretty often that I’ve put in ~/.zshrc. I’ve put them here since they could be helpful for someone else. Some are much, much simpler than others, but I’ve put them here anyway. It’ll be updated as time passes.

alias cat='bat' # requires bat (
alias realcat='/bin/cat' # if i ever need to go back to good old cat
alias rm='trash' # requires trash (
alias reloadrc='exec zsh' # meta
# NOTE: Does not work with the Warp terminal, unfortunately; use source .zshrc instead
# obviously, requires neovim to be installed (
vim() { # self-explanatory
  nvim $@
mkcd() { # saves me a few keystrokes
  mkdir $1
  cd $1
# requires coreutils to be installed (, can be done with brew install coreutils on macOS
gzipped() { # see how much you'd save using gzip (pass the path to the file and a level 1-9, e.g. gzipped /path/to/file 9
  echo Compressed: $(gzip -$2 -c $1 | wc -c | numfmt --to=iec-i --suffix=B --padding=10)
  echo Original: $(cat $1 | wc -c | numfmt --to=iec-i --suffix=B --padding=10)
timeshell() { # time your shell startup (taken from
  for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done

Leave a Reply

Your email address will not be published. Required fields are marked *