Some Linux terminals especially remote ones look lifeless. In this post I want to show in 10 min, how hugely you can improve interaction experience with those terminals by using aliases, customising command prompt and
ls output, and adding history date.
This one is top priority: define as many as aliases that saves your time in typing. There are many long commands that you type many times a day, make aliases for them like:
alias workssh="ssh firstname.lastname@example.org" alias hgrep="history | grep" alias current="cd '~/program1/bin/'"
Customise bash prompt
The default command prompt may look like this:
in plain white and not showing the current directory or any other information. To change that, we need to set
PS1 environment variable. The coloring code can be really confusing, to save time we use this free online bash PS1 generator. In the website, drag and drop items such as date, directory, and hostname. By clicking on each item, you can set the color of them. This is what I made:
Now copy-paste the
export PS1=blah blah blah into your terminal. You should immidiately see the change. Also you can paste the line into
~/bash_profile to make it as the default style.
Color ls output
ls colors are set in the environment variable
LS_COLORS. You can check if it is set in your terminal by running
The format of
LS_COLORS is like:
where filetype1, 2,… are specific file extensions like *.jpg, *.png or the below table
|NORMAL||Normal (nonfilename) text|
x1, x2,… are the codes which are picked from the table below
|30||for black FG|
|33||yellow (or brown) FG|
|37||white (or gray) FG|
|43||yellow (or brown) BG|
|47||white (or gray) BG|
This is the
LS_COLORS I have in
~/.bashrc of a remote server:
ls in a folder I get:
If you don’t see any color, there is a chance that coloring is off, add this into
alias ls="ls --color=auto"
As far as I’ve seen, bash history doesn’t store time and date of previous commands. To do so, add this to your
export HISTTIMEFORMAT="%d/%m/%y %T "
There has been times, I really needed the exact time that I deleted something and this helped me.
More like this
See this post that I show how you can systematically copy current path in a Shell terminal and use it somewhere else.
- A C++ MPI code for 2D unstructured halo exchange
- Essential bash customizations: prompt, ls, aliases, and history date
- Script to copy a directory path in memory in Bash terminal
- What is the difference between .bashrc, .bash_profile, and .profile?
- A C++ MPI code for 2D arbitrary-thickness halo exchange with sparse blocks