Oct 172012

From Lifehacker.com

If working in the Terminal gets a little confusing because you run so many commands at once, this little trick will put a separator in between each prompt so you can easily see the last few commands you ran. Blogger Emilis found that his bash prompt was getting a bit too cluttered, so he implemented this tweak to throw a long, dotted line between each command. He also bolded each command he ran, so he could easily scroll back and tell the difference between each command he ran and its output.

To use this on Linux, just copy the following code (available on GitHub as well), and put it in a new file called .bash_ps1 in your home folder:

# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="--- "
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
command_style=$reset_style'\[\033[1;29m\]' # bold black
# Prompt variable:

PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$'"$command_style "

# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\e[0m"' DEBUG

function prompt_command {

# create a $fill of all screen width minus the time string and a space:
let fillsize=${COLUMNS}-9
while [ "$fillsize" -gt "0" ]
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1

# If this is an xterm set the title to [email protected]:dir
case "$TERM" in
bname=`basename "${PWD/$HOME/~}"`
echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"


Then, run the following command in a Linux Terminal:
vim ~/.bashrc
Paste the following code into that file, hit Ctrl+X to save, press Y to confirm, and restart the Terminal.

if [ -f "$HOME/.bash_ps1" ]; then
. "$HOME/.bash_ps1"

You should see your new changes in effect. You should see separators between each command, and those commands will be in bold (while everything else is plain).
From Lifehacker.com

 Posted by at 1:15 pm

Sorry, the comment form is closed at this time.