SHARE WITH THE CLASS: What aliases are you using?

macallik@kbin.social to Linux@lemmy.ml – 139 points –

From bash to zsh and everywhere in between, show me yours and I'll show you mines. Inspire others or get some feedback.

Simply copy & paste the output of alias in your terminal or add some comments to explain things for others.

Edit: Kbin users, click 'More' on a comment and use the fediverse link to read responses that have funky formatting

114

You are viewing a single comment

A different way to do the usual ..="cd .." and endless chains of ...="cd ../.." types of aliases:

bash/ksh version:

..() {
    local count="${1:-1}"
    local path="../"
    while (( --count > 0 )); do
        path="$path../"
    done
    cd -- "$path"
}

zsh single-line version:

..() { cd $(printf "../%.s" {1..${1:-1}}) }

These take the number of directories that you want to move up as an argument (e.g. .. 3), otherwise they move you up one directory when used with no arguments.

There is a shell option for this (at least in zsh): setopt autocd. This allows you to change directories while omitting the cd in front