Skip to content

Tuesday, February 9th, 2010

Customizing the Cygwin Terminal

December 5, 2008 by Sravan  
Filed under Computers

Cygwine Terminal 

Cygwin loads its settings from a file called .profile present in the HOME environment variable. By default, HOME is set to /home/<username> which in Windows can be reached in C:\cygwin\home\<username> (assuming you have installed Cygwin in C:\cygwin folder).

.profile can be opened using any text editor. Here you can set colors to be displayed, prompt, history, aliases, default working directory, and any banner you may wish. The colors you choose will interfere with the colors set in your command prompt.

Below is a sample .profile.

————————————————————————————————–
# .profile

# Define some colors first:
red=’\e[0;31m'
RED='\e[1;31m'
green='\e[0;32m'
GREEN='\e[1;32m'
yellow='\e[0;33m'
YELLOW='\e[1;33m'
blue='\e[0;34m'
BLUE='\e[1;34m'
pink='\e[0;35m'
PINK='\e[1;35m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m'

# Colors and Prompt
export PS1="\[\e]2;\u@\h:\w\007$green\]\u@\h:\[$pink\]\w\[$blue\]$ \[$BLUE\]“          # Word wrap of previous line.

set -o vi
export EDITOR=vi

# History
export HISTSIZE=1000
export HISTFILE=~/.bash_history
export HISTFILESIZE=1000

# Various Aliases
alias dir=’ls –color=auto’

# Working directory
cd /e/home

# Banner
echo -e “${cyan}”
echo \ \ \ \ \ #======================#
echo \ \ \ \ \ # Welcome back Sravan!\ #
echo \ \ \ \ \ #\ \ \ I missed you.\ \ \ \ \ \ #
echo \ \ \ \ \ #======================#
echo
————————————————————————————————–

The above .profile first defines some colors. One could directly use the color codes but this is more readable. Next, it sets the prompt settings. We’ll go over what the PS1 line exactly means later. The script then sets output display settings, history file settings, aliases, default working directory and banner. Comments are prefixed with a #.

You might have to tweak some color combinations in the PS1 line. I use a variant of the above .profile in combination with a command prompt with colors mainly set to a white background and a blue text as against the default black background and a white text. This is more pleasant to my eyes, giving me a white board and a blue marker feeling.

Let me know if you need further help with this. I’m not going into detail because it is off-putting to discuss too much about colors here.

Image Source: Cygwin screenshot from my PC.

  • StumbleUpon
  • Digg
  • Facebook
  • Mixx
  • Google
  • TwitThis
  • Reddit
  • Yahoo! Buzz
  • Slashdot
  • E-mail this story to a friend!
  • BallHype
  • YardBarker

Comments

4 Responses to “Customizing the Cygwin Terminal”
  1. Anthony says:

    hi .. do you know if there’s a way to apply word-wrap to cygwin?
    thanks

  2. Sravan says:

    If you see the .profile above, we are setting the editor to ‘vi’, and AFAIK there is no word-wrap in Vi. But I’m not so sure.

Trackbacks

Check out what others are saying about this post...
  1. [...] have seen a few things about the .profile while customizing the Cygwin terminal. Here are the remaining sections of the [...]

  2. [...] Cygwin like for any Unix-based OS. For this reason, you might see its users like me chasing after fancy ways of beautifying it. Well, I will try to make this the last [...]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!


About Us | Advertise with us | Blog for EveryJoe | Privacy Policy | Terms of Use
Get This Theme | Sitemap


All content is Copyright © 2005-2010 b5media. All rights reserved.