Hide the current working directory in terminal

posted on 25th Nov, 2011

In Ubuntu as a default, the terminal prompt will show the current working directory, but as you dig deeper into a file structure you will have less and less space to type commands.

There are a number of prompts that you may come across PS1 is the default, this is a value stored as a environment variable called PS1. To see its current value, type echo $PS1

To change it, you can set a new value for the variable:

This will only show the user@host in the prompt. To make the change permanent, append to the end of ~/.bash_profile (or ~/.bashrc).

If you really want something more minimal you can try this:

If your feeling creative you can even add some colours like so:

Here's a list of shorthand that you can use when composing these:

  • \a The 'bell' charakter
  • \A 24h Time
  • \d Date (e.g. Tue Dec 21)
  • \e The 'escape' charakter
  • \h Hostname (up to the first ".")
  • \H Hostname
  • \j No. of jobs currently running (ps)
  • \l Current tty
  • \n Line feed
  • \t Time (hh:mm:ss)
  • \T Time (hh:mm:ss, 12h format)
  • \r Carriage return
  • \s Shell (i.e. bash, zsh, ksh..)
  • \u Username
  • \v Bash version
  • \V Full Bash release string
  • \w Current working directory
  • \W Last part of the current working directory
  • \! Current index in history
  • \# Command index
  • \$ A "#" if you're root, else "$"
  • \\ Literal Backslash
  • \@ Time (12h format with am/pm)

Comments

  • Latanya

    02:39 on 1st Dec, 2011

    good post, added you to my RSS reader.

    Reply

Leave a comment

Comment

GitHub Projects
Tunes