• Martin Thoma
  • Home
  • Categories
  • Tags
  • Archives
  • Support me

Make your Bash more useful

Contents

  • Make your Bash more useful
    • Change the prompt
    • Aliases

I just had the problem, that the bash prompt of my universities computer I've connected to via SSH looked like this: bash-4.0$

Change the prompt

I think it's much more useful to see the path you're currently using. To get the current path in your bash promt, you have to add the following snippet to your .bashrc:

# This will limit the path to 30 characters.
PROMPT_COMMAND='if [ ${#PWD} -gt 30 ]; then
myPWD=${PWD:0:12}...
${PWD:${#PWD}-15}; else myPWD=$PWD; fi'
PS1="\[email protected]\h \$myPWD$ "

(Source: cyberciti.biz)

Reload your bash config with source .bashrc and you should instantly see the changes.

Aliases

# Add color to ls
alias ls="ls --color"
# simply update an svn-repository
alias swt='svn up /home/moose/Studium/SWT'

Published

Nov 29, 2012
by Martin Thoma

Category

Code

Tags

  • Bash 7
  • Linux 17

Contact

  • Martin Thoma - A blog about Code, the Web and Cyberculture
  • E-mail subscription
  • RSS-Feed
  • Privacy/Datenschutzerklärung
  • Impressum
  • Powered by Pelican. Theme: Elegant by Talha Mansoor