Change root in a bash shell.


/ Published in: Bash
Save to your folder(s)

This is for debian but can be adapted with little trickery to any Linux distro. This enables changing the root of a shell so that the directories displayed are not too long.

Useful for dir-verbose frameworks like symfony or when managing a huge website directory.

Usage: setroot $PWD


Copy this code and paste it in your HTML
  1. function setroot
  2. {
  3. web_root=$1
  4. PS1='${debian_chroot:+($debian_chroot)}\u@\h:$(echo \w| sed s@'$web_root'@@g)\$ \[\033k\]$(basename "\w")\[\033\\\]'
  5. export PS1
  6. alias ca="cd $PWD"
  7. }
  8.  
  9. # this can be adapted

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.