LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Blogs > NullTerminator
User Name
Password

Notices

Rate this Entry

bashrc tweak - colors in ssh ession

Posted 09-10-2012 at 01:06 PM by NullTerminator
Updated 09-18-2012 at 09:39 AM by NullTerminator

If you use any of a number of remote ssh clients and want to improve the color selection, here's a how to. Please credit the original authors. I'm just making it easier to find.

excellent ref @ http://ubuntuforums.org/archive/index.php/t-41538.html
Code:
 1. Edit the '.bashrc' file. You need to make a few small changes to the existing bash script.

(optional) Backup the file. Copy your existing '.bashrc' file in case you wish to restore it at a latter time. For example,

Modify the file. Using your favorite text editor, open the file '~/.bashrc' and make the following changes hilighted in red (which should appear somewhere near the top of that file - line 17 if no prior alterations were made). You will basically be modifying one line and adding two more above it.

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
[ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors"
[ -e "$DIR_COLORS" ] || DIR_COLORS=""
eval "`dircolors -b $DIR_COLORS`"
alias ls='ls --color=auto'
#alias dir='ls --color=auto --format=vertical'
#alias vdir='ls --color=auto --format=long'
fi

2. Create the '.dircolors' file. The '.dircolors' file is created by using the 'dircolors' program. It will generate a default color scheme to be used with the "LS_COLORS" environment variable, which gives the colored output while using "ls".
[user@server currdir]$ cd && dircolors -p > .dircolors
3. Edit the '.dircolors' file. Here is where you will be modifying/creating new color schemes to reflect your own unique style.

NOTE: Lines 34-41 within this file give you the color codes for three specific keys: attribute, text, and background. You can choose to use all three keys, or simply pick and choose only those keys you wish to apply. Look at some of the pre-defined ones you may already recognize as a good example to follow.

Modify existing color schemes. For example, I can't stand big bold blue directory listings, so I change the bold attribute from "01" to "00" (none) but keep the blue color. It will lighten things up a bit.
FILE 00 # normal file
DIR 01;33 # directory - bold yellow
LINK 00;33 # symbolic link. - normal yellow
or, change the "01" to an "07", making your debian packages really stand out!
.gz 01;31
.bz2 01;31
.war 01:31 # bold red


SOURCE the bashrc   .
Source the '.bashrc' file. In order for your changes to take effect within the current shell, you need to source the '.bashrc' file.
[user@server currdir]$ cd && . .bashrc
/*********************************************************************************************************************/

Also hint for  vi, vim
set background=dark helps with the blue comment color

ref http://hintsforums.macworld.com/archive/index.php/t-16493.html
also insert this line in end of bash_profile to source the bashrc file for new term sessions.
It may already be in there....
if [ -f ~/.bashrc ]; then . ~/.bashrc ; fi
Posted in Uncategorized
Views 535 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 01:31 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration