Tag Archives: Bash

Unix: Useful and pretty prompt

Some servers at work has varying degrees of useful prompts when I connect to them through SSH. Usually they are quite annoying and for example showing the shell type and version, which I frankly don’t care much about. Here’s how to make it show the current user, hostname and working directory. In addition the hostname is made more visible, which is a nice effect.

$ bold=$(tput bold)
$ reset=$(tput sgr0)
$ export PS1="\u@\[$bold\]\h\[$reset\]:\w\$ "

Stick it in your .profile, .bash_profile or whatever else you’ve got going on to make it more permanent.

How to make the Bash command prompt more useful

Was on a Linux box today and I found the command prompt rather useless. It looked like this:

-bash-3.2$

I know I’m using bash, and I don’t really care about the version. Or that I’m using bash actually… But anyways, to make it more useful you can run this:

$ PS1="\u@\h:\w$ "

You will then get a prompt which contains your username, hostname and current working directory. Much more useful in my opinion. If you have a different opinion, please share 🙂

You can find more stuff to put in your prompt by reading the prompting section of the bash man page.