Seeing your
up
alias reminded me of a bash function I setup a while ago also calledup
. I use it to simulate doingcd ..
n number of times. e.g.up 5
would go up 5 directory levels.up () { local levels; local i; [[ -z "$1" ]] && levels=1 || levels="$1"; for ((i=0; i<levels; i++)) do cd ../; done }
It’s probably the smallest, yet most convenient thing I’ve setup on my machines. Especially so if you work in languages with lots of nested subdirectories (like Java).
i setup several aliases
alias ..='cd ..' alias ...='cd ../../.' alias ...='cd ../../../.' alias ....='cd ../../../../.'
and so on…
Yup, aliases are super useful! One of my most used ones is
mkcd
; you almost always want to cd into a dir after you make it.I also like fish’s abbreviations (created through
abbr
), which are essentially aliases that get expanded when you run them. For example, if I set an abbreviation withabbr -a dkc docker-compose
, I can then just typedkc
and it will expand it to the full command when I either hit enter or space.