A nice shell prompt for bash, and an easy text editor for Cygwin

I recently installed Cygwin with bash as my preferred shell.  Most shell prompts simply give you a $ or # sign by default.  You don't know where you are in the directory structure unless you type pwd.  There is a simple line you can place in your .bashrc file in your Cygwin home directory (C:\Cygwin\home\userid).

If you don't have a text editor or aren't familiar with the UNIX editors such as vi (bvi) or emacs, I'd recommend nano.  If you don't have nano installed (check by simply running nano in the Cygwin window).  You can install that by re-running the Cygwin setup.exe in Windows.  In the setup, expand the Editors section and click the area to the left of Nano until you can check its checkbox, then proceed with the setup.  nano has more of a Notepad-like interface than anything else I've seen.  To edit your .bashrc file with nano, simply type:
nano .bashrc
Scroll down to the bottom (use your arrow keys or press Ctrl-V).  Add the following line:
export PS1="[\u@\h:\w]\$ "
Press Ctrl-X and type "Y" when asked to save the modified buffer (basically, save the file).  Press enter to save the file with the existing filename: .bashrc

You can close the window and then start Cygwin again, but there's also a quick and dirty way to "reboot" the config without restarting Cygwin.  From the shell prompt, type:
source .bashrc
This will cause the shell to reload the configuration and show the changes immediately.  You should now see a nice prompt which looks something like this:

 [user@mypc:~]$


Now when you change directories, say, cd /usr/local/bin, you'll always know where you are without having to type pwd all the time, like so:

[user@mypc:~]$:/usr/local/bin]$



Comments

Popular posts from this blog

How to block the Admiral anti ad-block detection message

Domain registrar pricing comparison (2014)

usoclient.exe in Windows 10 wakes up my PC with Wake Source: Unknown