You are not logged in.
Edit: Solution from Seth: https://bbs.archlinux.org/viewtopic.php … 4#p1973484 (this thread)
Hi, I have some zsh aliases (e.g. 'data') to speed up 'cd'-ing to common directories, but they produce what looks like an incorrect error message:
(anon):cd: no such file or directory: /mnt/DATA/down*when the directory /mnt/DATA/download exists
It seems like zsh won't expand the * ... sometimes.
Prompts below are B=bash, Z=zsh followed by $PWD - some blank lines inserted for readability.
Z:/home/username : alias data
data='(){ cd /mnt/DATA/$1}'
Z:/home/username : data # works
Z:/mnt/DATA : data download # works
Z:/mnt/DATA/download : cd
Z:/home/username : data down* # doesn't work
(anon):cd: no such file or directory: /mnt/DATA/down*
Z:/home/username : cd /mnt/DATA/down* # I can cd to the 'no such directory'...
Z:/mnt/DATA/download : Now switch to bash, where 'data' is defined differently but '*' works:
Z:/home/username : bash
B:/home/username : alias data
alias data='. ddata'
B:/home/username : cat `which ddata`
#!/bin/bash
cd:/mnt/DATA/$1
B:/home/username : data down*
B:/mnt/DATA/download :
B:/mnt/DATA/download : data down*/tem*
B /mnt/DATA/download/temp : Aliasing 'data' to the same thing in zsh didn't work, with either '#!/bin/bash' or '#!/bin/zsh', giving the same
'no such file or directory: /mnt/DATA/down*' error.
zsh 5.8 (x86_64-pc-linux-gnu)
Last edited by Flemur (2021-05-18 11:41:48)
"If you do not change direction, you may end up where you are heading." -- L.T.
Offline
That appears to be a function, not an alias. The shell would expand the glob before passing it to the function.
Edit: Actually, I'm wrong. It's passing it just fine, but the zsh one is in single quotes, so it won't expand.
Last edited by Scimmia (2021-05-17 16:39:40)
Offline
That appears to be a function, not an alias. The shell would expand the glob before passing it to the function.
Edit: Actually, I'm wrong. It's passing it just fine, but the zsh one is in single quotes, so it won't expand.
With similar aliases, zsh won't do what I can do in bash:
B /home/username : alias data
alias data='. ddata'
B /home/username : cat `which ddata`
#!/bin/bash
cd /mnt/DATA/$1
B /home/username : data down*
B /mnt/DATA/download : data dow*/te*
B /mnt/DATA/download/temp : In zsh, change 'data' alias so it's like in bash, above, but get the same error:
Z:/home/username : alias data
data='. zddata'
Z:/home/username : cat `which zddata`
#!/bin/ksh
cd /mnt/DATA/$1
Z:/home/username : data down*
/home/username/bin/zddata:cd:2: no such file or directory: /mnt/DATA/down*
Z:/home/username :Is there a way to make this work in zsh?
This works, but I'm trying to avoid typing /mnt/DATA all the time:
Z:/home/username : cd /mnt/DATA/do*/te*
Z:/mnt/DATA/download/temp : "If you do not change direction, you may end up where you are heading." -- L.T.
Offline
Semi-solution: make smarter use of zsh...
Z:/home/username : alias data
data='(){ cd /mnt/DATA/$1}'
Z:/home/username : data;do*/te*
Z:/mnt/DATA/download/temp : I'll probably cuss a bunch until I get used to typing the ';'
You can also enter the full dir names:
$ data download/temp
Z:/mnt/DATA/download/temp :
Last edited by Flemur (2021-05-17 18:04:40)
"If you do not change direction, you may end up where you are heading." -- L.T.
Offline
Maybe also look into fzf and its builtin key-bindings (alt-c) for quick fuzzy-search assisted directory jumping?
"the wind-blown way, wanna win? don't play"
Offline
alias data='cd /mnt/DATA; HOME=. cd'You move to the target directory first, then handle the globbing as usual.
Setting the HOME environment to "cd" takes care of the emtpy case (otherwise "cd" would change to ~)
Offline
alias data='cd /mnt/DATA; HOME=. cd'You move to the target directory first, then handle the globbing as usual.
Setting the HOME environment to "cd" takes care of the emtpy case (otherwise "cd" would change to ~)
That works great, thanks! SOLVED.
Edit: also works in bash & ksh.
Last edited by Flemur (2021-05-18 15:54:13)
"If you do not change direction, you may end up where you are heading." -- L.T.
Offline