LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   catalogs names shortcuts (https://www.linuxquestions.org/questions/linux-newbie-8/catalogs-names-shortcuts-726372/)

netimen 05-16-2009 04:24 AM

catalogs names shortcuts
 
How can I set catalogs names shorcuts for not typing
Code:

cd ~/Documents/work/Evg/biblatex
but
Code:

cd working_dir_shortcut_name

druuna 05-16-2009 04:35 AM

Hi,

There are more ways, here are 2:

1) Create and export a variable.

Put something like this in your .bashrc or .profile: export EVG="/home/<USERNAME>/Documents/work/Evg/biblatex".
After your next login you can do something like this: cd $EVG

2) Create an alias.

Put something like this in your .bashrc or .profile: alias cdevg="cd ~/Documents/work/Evg/biblatex".
After your next login you can do this: cdevg

Hope this helps.

netimen 05-16-2009 04:42 AM

Yeah, thanks! thats exactly what I did want )

ArfaSmif 05-16-2009 05:28 AM

There are other ways to do this (IMHO more elegant) by using the CDPATH variable in your shell. For example, you can use something like the following in your .bashrc file :-

export CDPATH=.:~:~/documents:~/ftps:~/bin:~/videos:~/pictures:~/bin:~/muzak:$PATH

which will allow you to change to the any of the mentioned directories simply by typing in, for example :-

$ cd muzak

from anywhere and you will change to the /home/username/muzak directory. It is similar to the PATH variable. Do a "man bash" (if you are using bash as your shell) to get all the info.

In your case you would need something like:-

export CDPATH=.~:~/Documents:~/Documents/work:~/Documents/work/Evg:~/Documents/work/Evg/biblatex

netimen 05-16-2009 06:39 AM

Thank you, ArfaSmif but this adds to many folders to the gloabal namespaces. For Example I have 14 folders in my Documents folder and want to have a shortcut only to one of them — if I use your method I'll get all the other 13 folders in the quick access

netimen 05-16-2009 06:42 AM

Quote:

Originally Posted by druuna (Post 3542620)
Hi,
1) Create and export a variable.

Put something like this in your .bashrc or .profile: export EVG="/home/<USERNAME>/Documents/work/Evg/biblatex".
After your next login you can do something like this: cd $EVG

But can I make autocompletion work like with ~:

When I type
Code:

cd ~/Do
and press Tab it expands to
Code:

cd /home/netimen/Documents/
Can I have something like this: when I type
Code:

cd $workdir/n
and press Tab it expands to
Code:

cd ~/Documents/work/Evg/biblatex/new

druuna 05-16-2009 06:49 AM

Hi,

When using my first example (export EVG="/home/<USERNAME>/Documents/work/Evg/biblatex") that should work (it does on my side):

Code:

$ export TST="/home/druuna/_Schuur"
$ echo $TST
/home/druuna/_Schuur

$ cd $TST/P  (press TAB and it becomes like the next line shown)
$ cd /home/druuna/_Schuur/Perl/

$ pwd
/home/druuna/_Schuur/Perl

The ~ is expanded by bash.

netimen 05-16-2009 07:02 AM

Quote:

Originally Posted by druuna (Post 3542692)
Hi,
When using my first example (export EVG="/home/<USERNAME>/Documents/work/Evg/biblatex") that should work (it does on my side):

Yeah, I did exactly what you said, but it doesn't expand, though I can use
Code:

cd $EVG
and go to the biblatex folder.

The behavior of TAB is following. When I type
Code:

cd $E
and press TAB, it changes to
Code:

cd \$E
and when I type
Code:

cd $EVG/n
TAB does nothing

druuna 05-16-2009 08:03 AM

Hi again,

I think I misunderstood your question.

The variable (EVG in this case) should expand as well. If more 'things' are defined that start with a E, it will not expand (2xtab will show all that start wit E):

Code:

$ echo $DLS
/data/Downloads

[exile] druuna ~ $ cd $D  (one tab, nothing happes)

[exile] druuna ~ $ cd $D  (2xtab, all possibilities are shown)
$DIRSTACK  $DISPLAY  $DLS

[exile] druuna ~ $ cd $DL (typed first to chars then tab, line becomes:)
[exile] druuna ~ $ cd $DLS
[exile] druuna /data/Downloads $

I'm not sure why the $E becomes \$E when you press tab. It could be a bash environment setting, but I wouldn't know which one.

BTW: It is good practise to always type the first 2 chars before pressing tab

ArfaSmif 05-16-2009 06:54 PM

Quote:

Originally Posted by netimen (Post 3542687)
Thank you, ArfaSmif but this adds to many folders to the gloabal namespaces. For Example I have 14 folders in my Documents folder and want to have a shortcut only to one of them — if I use your method I'll get all the other 13 folders in the quick access

absolutely true ...

netimen 05-17-2009 05:51 AM

Quote:

Originally Posted by druuna (Post 3542727)
I think I misunderstood your question.

Yeah, when I type
Code:

cd $EV
and press TAB I get
Code:

cd \$EVG
but if I type
Code:

cd $EVG/
and press TAB even many times I get nothing


All times are GMT -5. The time now is 02:40 AM.