Skip to content

Latest commit

 

History

History
58 lines (37 loc) · 1.41 KB

nifty_aliases.md

File metadata and controls

58 lines (37 loc) · 1.41 KB

Nifty Aliases

This is a collection of some nifty Shell aliases.

$PATH is a mess

If you echo $PATH to inspect it, you will see that it is a mess and not as easy to work with as for example the output of env.

echo $PATH

This is a nifty command line construct to help you:

echo $PATH | tr ':' '\n'

It outputs $PATH as multiple lines, so you can pass it to grep or similar.

echo $PATH | tr ':' '\n' | grep jonasbn

And finally you can create a nifty alias:

alias path="echo $PATH | tr ':' '\n'"

And it just works:

path | grep jonasbn

rm is pretty destructive

Lifted from the TIL: "Are you sure?.

This might be the oldest trick I learned when I started using rm and mv on the command line on Linux ages ago.

The trick is to use the -i option to rm and mv to make sure you are not deleting or moving the wrong files.

alias rm='rm -i'

By creating an alias for rm you will be prompted for confirmation before deleting files, since the alias will let rm be replaced by rm -i which prompts for confirmation.

The same pattern can be used for other commands and simple as it is it can be a lifesaver.

cp and mv can be destructive

alias mv="mv -v -n" # verbpse and prompt interactively if file already exist
alias cp="cp -v -i" # vervose and prompt interactively if file already exist