AnnouncementsMatrixEventsFunnyVideosMusicBooksProjectsAncapsTechEconomicsPrivacyGIFSCringeAnarchyFilmPicsThemesIdeas4MatrixAskMatrixHelpTop Subs
3

. in PATH

One of my favourite Operating Systems is DOS. Programs for it are portable, so instead of relying on a PATH, each program has its own folder that includes the binary. As a result of this, the command interpreter looks for matching programs in the local directory first. This can be done in unix systems by adding . to the PATH. This is seen as a security threat because a directory may contain malicious programs named ls or anything else that's commonly used, and then that will run instead of /usr/bin/ls, but this threat is eliminated by adding . to the end of the PATH. (This way it can never override an existing program.)

In bash:
echo 'export PATH="$PATH:."' >> ~/.bashrc

In fish:
fish_add_path --append .

Move up multiple directories

The other feature I like is that cd ... moves up two directories, and each additional dot moves up an additional directory. This can be implemented with a function.

In bash:

# Add to ~/.bashrc
shopt -s autocd

alias ...='../..'
alias ....='../../..'
alias .....='../../../..'
alias ......='../../../../..'

In fish:

# Add to ~/.config/fish/config.fish
abbr -g ...  '../..'
abbr -g .... '../../..'
abbr -g ..... '../../../..'
abbr -g ...... '../../../../..'

As you can see, it's defined manually per number of steps up. I wanted to keep the code easily readable. You can also use a function that wraps around cd which uses recursion to traverse an arbitrary number of directories upwards. However, if you want to keep on writing cd in the terminal as you're likely used to, you'd have to name that function itself cd(). I don't like touching such fundamental functions and potentially breaking other programs that rely on it for something so trivial. Expanding the dots is a bit less elegant but covers 99% of use cases most likely.

Comment preview