Here are some small, simple, but surprisingly useful shell commands that I use everyday. Hopefully, you may find it useful too.
Change Directory and List Content
alias cd..='cd ..' alias cd...='cd ../..' cl() { cd $1 && ls }
The functions of these commands are self-explanatory and may seem trivial on the first sight. But since ls
and cd
are the most common shell commands we use everyday, these shortcuts will save you a tremendously amount of key stokes in the long run.
List Sub-directories Only
alias lsd=alias lsd='ls -F | grep / | sed -e '\''s/\///g'\'' | column'
Say that you are in a large code base (for instance, the Linux kernel) and you want to see if a particular sub-directory exists but do not want to clutter the output from the ls
command with all the ordinary files, then this shortcut comes in handy.
Trash instead of Delete
alias trash="mv -t ~/.Trash --backup=t"
This command moves files into a specific location instead of delete them permanently. It is the shell version trash can utility usually found in a GUI environment. Note that in Ubuntu, you might want to replace ~/.Trash
with~/.local/share/Trash/files
, the standard location for trashed objects.