How do I create a symbol to represent a path to easily cd into a directory?

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?
bash shell directory cd-command
add a comment |Â
up vote
1
down vote
favorite
In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?
bash shell directory cd-command
1
Related - unix.stackexchange.com/questions/31161/â¦. This Q&A has a whole host of tools to help navigate directories via CLI.
â slmâ¦
Jul 5 at 19:06
Put this to your .bashrc:[[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
â Cyrus
Jul 5 at 19:08
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?
bash shell directory cd-command
In the same way that cd ~ directs you to your home directory, is it possible to create another symbol, @ for example, such that cd @ would take me to /my/working/directory?
bash shell directory cd-command
edited Jul 5 at 18:58
Jeff Schaller
30.8k846104
30.8k846104
asked Jul 5 at 18:54
thecommonwealthcollective
82
82
1
Related - unix.stackexchange.com/questions/31161/â¦. This Q&A has a whole host of tools to help navigate directories via CLI.
â slmâ¦
Jul 5 at 19:06
Put this to your .bashrc:[[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
â Cyrus
Jul 5 at 19:08
add a comment |Â
1
Related - unix.stackexchange.com/questions/31161/â¦. This Q&A has a whole host of tools to help navigate directories via CLI.
â slmâ¦
Jul 5 at 19:06
Put this to your .bashrc:[[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~
â Cyrus
Jul 5 at 19:08
1
1
Related - unix.stackexchange.com/questions/31161/â¦. This Q&A has a whole host of tools to help navigate directories via CLI.
â slmâ¦
Jul 5 at 19:06
Related - unix.stackexchange.com/questions/31161/â¦. This Q&A has a whole host of tools to help navigate directories via CLI.
â slmâ¦
Jul 5 at 19:06
Put this to your .bashrc:
[[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~â Cyrus
Jul 5 at 19:08
Put this to your .bashrc:
[[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~â Cyrus
Jul 5 at 19:08
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Two options come to mind:
Use a variable:
w="/my/working/directory"
cd "$w"Use an alias:
alias cdw='cd /my/working/directory'
cdw
add a comment |Â
up vote
2
down vote
You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.
mkdir ~/dir_aliases
ln -s /path/to/alias ~/dir_aliases/@
ln -s /another/path ~/dir_aliases/%
...
Then add this dir to CDPATH (probably in .bashrc or similar)
CDPATH=~/dir_aliases
Typing
cd @
will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to
cd $(readlink -f .)
to see the real path.)
cd -Pis a simpler way than usingreadlinkto use the real path.
â jamesdlin
Jul 18 at 7:54
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Two options come to mind:
Use a variable:
w="/my/working/directory"
cd "$w"Use an alias:
alias cdw='cd /my/working/directory'
cdw
add a comment |Â
up vote
1
down vote
accepted
Two options come to mind:
Use a variable:
w="/my/working/directory"
cd "$w"Use an alias:
alias cdw='cd /my/working/directory'
cdw
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Two options come to mind:
Use a variable:
w="/my/working/directory"
cd "$w"Use an alias:
alias cdw='cd /my/working/directory'
cdw
Two options come to mind:
Use a variable:
w="/my/working/directory"
cd "$w"Use an alias:
alias cdw='cd /my/working/directory'
cdw
edited Jul 12 at 16:11
Kusalananda
101k13199312
101k13199312
answered Jul 5 at 18:58
nohillside
1,856616
1,856616
add a comment |Â
add a comment |Â
up vote
2
down vote
You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.
mkdir ~/dir_aliases
ln -s /path/to/alias ~/dir_aliases/@
ln -s /another/path ~/dir_aliases/%
...
Then add this dir to CDPATH (probably in .bashrc or similar)
CDPATH=~/dir_aliases
Typing
cd @
will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to
cd $(readlink -f .)
to see the real path.)
cd -Pis a simpler way than usingreadlinkto use the real path.
â jamesdlin
Jul 18 at 7:54
add a comment |Â
up vote
2
down vote
You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.
mkdir ~/dir_aliases
ln -s /path/to/alias ~/dir_aliases/@
ln -s /another/path ~/dir_aliases/%
...
Then add this dir to CDPATH (probably in .bashrc or similar)
CDPATH=~/dir_aliases
Typing
cd @
will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to
cd $(readlink -f .)
to see the real path.)
cd -Pis a simpler way than usingreadlinkto use the real path.
â jamesdlin
Jul 18 at 7:54
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.
mkdir ~/dir_aliases
ln -s /path/to/alias ~/dir_aliases/@
ln -s /another/path ~/dir_aliases/%
...
Then add this dir to CDPATH (probably in .bashrc or similar)
CDPATH=~/dir_aliases
Typing
cd @
will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to
cd $(readlink -f .)
to see the real path.)
You can use the CDPATH variable to simulate it. Just create a directory with soft links to the destination paths, e.g.
mkdir ~/dir_aliases
ln -s /path/to/alias ~/dir_aliases/@
ln -s /another/path ~/dir_aliases/%
...
Then add this dir to CDPATH (probably in .bashrc or similar)
CDPATH=~/dir_aliases
Typing
cd @
will take you to ~/dir_aliases/@. (Unfortunately, the link path will be shown, you'll have to
cd $(readlink -f .)
to see the real path.)
answered Jul 12 at 16:14
choroba
24.1k33967
24.1k33967
cd -Pis a simpler way than usingreadlinkto use the real path.
â jamesdlin
Jul 18 at 7:54
add a comment |Â
cd -Pis a simpler way than usingreadlinkto use the real path.
â jamesdlin
Jul 18 at 7:54
cd -P is a simpler way than using readlink to use the real path.â jamesdlin
Jul 18 at 7:54
cd -P is a simpler way than using readlink to use the real path.â jamesdlin
Jul 18 at 7:54
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f453710%2fhow-do-i-create-a-symbol-to-represent-a-path-to-easily-cd-into-a-directory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Related - unix.stackexchange.com/questions/31161/â¦. This Q&A has a whole host of tools to help navigate directories via CLI.
â slmâ¦
Jul 5 at 19:06
Put this to your .bashrc:
[[ ! -e ~/@ ]] && ln -s /my/working/directory ~/@; CDPATH=~â Cyrus
Jul 5 at 19:08