Table of contents
Some aliases that I find useful
In all the following examples, the dollar sign
$at the beginning of commands represents the prompt, it should not be typed.
List all aliases
Prints all of your aliases. If you have plenty of those, you might
prefer to pipe this command with
less to get a nice pager that allows
you to easily nagivate them:
$ alias | less
Setting an alias in
This would set
c as a shortcut to
clear. In order to use the
newly created alias, you would have to close the terminal or type the
following command in the terminal:
$ source ~/.bash_aliases
Clear the screen
I like being absorbed into the emptiness of the terminal, so this one comes in handy to tidy up the work space.
Reset the terminal
alias re='tput reset'
If for some reasons the terminal displays badly or display funky characters, it can usually be reset this way.
Exit from the terminal
For exiting the terminal as if you were still in Vim!
Display all file extensions recursively from the current directory
alias allextensions="find . -type f -name '*.*' | sed 's|.*\.||' | sort -u"
It comes in handy to spot if a file shouldn’t be there or to check for lower or uppercase extensions.
Find text inside files, including filenames
alias findinfiles='ag --nobreak --nonumbers --noheading . | fzf'
In this example, the alias is set up with ag, a fast code-searching tool and fzf, a great fuzzy finder.
Reboot and shutdown the system
alias reboot='systemctl reboot' alias shutdown='systemctl poweroff'
This will reboot or power off the system without needing root privileges in most working conditions.
List and sort files and directories by modification time
alias treeold='tree -hDF | less'
This requires the command
tree to be installed. The parameters are
(descriptions taken from
-h: Print the size of files in a human readable way.
-D: Print the date of the last modification time.
-F: Append a ‘
/‘ for directories, a ‘
=‘ for socket files, a ‘
for executable files, a ‘
>‘ for doors (Solaris) and a ‘
FIFO’s, as per
Open files quickly with default applications
This will open files and URLs specified as argument in the default application detected.
If you are going to be working on projects for some time and require to
cd into them, I have found the following to be useful:
$ cdnameOfProject # instead of having to do cd /path/to/project/ $ # More examples: $ cdcodeabbey # For codeabbey.com $ cdhackerrank # For hackerrank.com $ cdeuler # For projecteuler.net $ cdgit # For all Github repositories
This is not advanced by any means, but it helps quite regularly! Since
you can take advantage of tab completion, you can type
adding a space) and then press
TAB key to autocomplete the aliases.
alias ...='cd ../..'
Make it easier to navigate into deep directory structures by basically
cd .. && cd .. to go back up two directories at once.
alias l='ls -CFh' alias la='ls -Ah' alias ll='ls -ahlF' alias ls='ls --color=auto'
Different ways to set up the command ls to quickly see the needed files.
The parameters are (descriptions taken from
-A: Do not list implied
-C: List entries by columns.
-F: Append indicator (one of
\*/=>@|) to entries.
-a: Do not ignore entries starting with .
-s, print human readable sizes (e.g., 1K 234M 2G).
-l: Use a long listing format.
alias aNameOfProject='source /path/to/project/bin/activate' alias aa='source ~/Programming/anaconda3/bin/activate' # Example using Anaconda distribution
The purpose is to activate a specific virtual environment quickly. The
cd could be added to go to the related project also:
alias gNameOfProject='cd /path/to/project/ && ./.venv/bin/activate'
.venv would be the name of the virtual environment.
I like to activate environments starting aliases with
a and go
and activate at the same time starting aliases with
g. This way, it
feels like I am speaking the Vim language (
cw for change word,
This will deactivate a virtual environment.
alias p36='python3.6' alias p='python3.7' # Simply using `p` for main version of Python
Practical way to quickly open the desired Python version.
alias pyclean='find . -regex ".*\(__pycache__\|\.py[co]\)" -delete'
This will delete recursively all files and directories that match one of
the following patterns in their name:
I hope you will find at least one alias to improve your productivity. Of course, you are welcome to chime in with your own suggestions!