You are not logged in.
Pages: 1
Hello guys,
I have an alias alias personal='cd /media/personal/files/' but I would love to use this inside other bash commands such as cd.
For example:
cd personal/music
rm personal/doc/file.txt
This would be really dreamlike. Is something like that achievable with bash?
Regards
Last edited by orschiro (2011-09-27 08:59:21)
Offline
I may be wrong, but AFAIK it's not. Aliases point to commands, while cd-ing can affect only dirs.
Edit: Wouldn't a symlink be enough here?
Last edited by bohoomil (2011-09-27 09:35:25)
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
In bash you can put e.g.
shopt -s cdable_vars
export apps="/home/karol/test/apps"
export usb="/media/usb"
export cachedir="/var/cache/pacman/pkg"
in your ~/.bashrc and then
[karol@black ~]$ cd apps
/home/karol/test/apps
[karol@black apps]$
Offline
I'm not quite sure if this solves my problem.
[bashrc]
shopt -s cdable_vars
export personal="/media/personal/robert"
Let's assume I want to open a folder 'share' in personal.
I would do 'cd personal/share' but bash cannot find the directory.
Last edited by orschiro (2011-09-27 10:21:39)
Offline
In ~/.bashrc set
test="/home/karol/test"
then
[karol@black ~]$ echo $test
/home/karol/test
[karol@black ~]$ cd $test/apps
[karol@black apps]$
Offline
'test' is just a variable, you need to call it like any other variable -'$test'.
I've heard that zsh is the ultimate interactive shell, you may want to try it out.
Offline
Pages: 1