Add Separator Line Between Commands in Linux Terminal

By Umair Tuesday, April 24, 2012

If you are a person who often perform daily tasks via command line interface, you might have ever performed multiple commands at once (usually by adding "&&" between them). But, you might be confused when analyzing the output of every command and when the command is finished. So today, I'd like to show you how to add a handy separator line between commands on Linux Terminal.

As you can see the picture above, at the end of every command there will be a separator line followed by the time completion of related command.
Now Please open your text editor and paste the following code:
 # 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)}\u@\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 user@host:dir  
   case "$TERM" in  
     bname=`basename "${PWD/$HOME/~}"`  
     echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"  

Save the above code as ".bash_ps1" (don't forget the dot character) and place it in your Home folder.

Now, edit your ".bashrc" file which is located in your Home folder and append the below code:
 if [ -f "$HOME/.bash_ps1" ]; then  
 . "$HOME/.bash_ps1"  

Save the change and run the following command to "apply" your work:
 source ~/.bashrc  


Bio: There is a lot information about Linux Geeks on the Internet.

1 comment to ''Add Separator Line Between Commands in Linux Terminal"

  1. This is a great tip...thank you for the post, just setup on my Mac