0

I've checked this.

But right now I'm working in a virtual env.

cam@cam:~$ cd Desktop/django-user3
cam@cam:~/Desktop/django-user3$ source newenv/bin/activate
(newenv)cam@cam:~/Desktop/django-user3$ cd superlists
(newenv)cam@cam:~/Desktop/django-user3/superlists$ 

Now i need to add an alias so that when i enter

cam@cam:~$ cd $DJANGO3

I need to get here.

(newenv)cam@cam:~/Desktop/django-user3/superlists$ 

but instead of this long path i need to see a shorter one.

Ajay
  • 133

1 Answers1

0

To shorten the prompt, one way is to set PROMPT_DIRTRIM:

$ cd /usr/share/man/man1
/usr/share/man/man1 $ PROMPT_DIRTRIM=3
.../share/man/man1 $

PROMPT_DIRTRIM, when set, limits the number of directories shown in the prompt path, replacing earlier parts with ....

There are other ways, such as removing unnecessary elements from them (such as the hostname). For that you'd need to edit PS1 in your .bashrc.

To create an alias, just string all your commands together. Aliasing cd just for this purpose isn't a very good idea. I'd use some other name, like django3:

alias django3='cd ~/Desktop/django-user3; source newenv/bin/activate; cd superlists; PROMPT_DIRTRIM=1'

Then you can do:

cam@cam:~ $ django3
(newenv)cam@cam:.../django-user3/superlists $
muru
  • 207,228