Zsh Mailing List Archive
Messages sorted by:
'...' in path names?
- X-seq: zsh-users 3163
- From: Dominik Vogt <dominik.vogt@xxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: '...' in path names?
- Date: Tue, 13 Jun 2000 17:54:17 +0200
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- Reply-to: dominik.vogt@xxxxxx
I really like to abbreviate something like '../../..' with '....'
(you get the idea). (The last time I tried to get it working was
zsh-3.0.5). I didn't get any farther than this:
alias '...'='cd ../..'
alias '....'='cd ../../..'
alias '.....'='cd ../../../..'
which works for '...' in the command position, but not in 'cd ...'.
Or altenratively I can get it working in positional parameters:
alias -g '...'='../..'
alias -g '....'='../../..'
alias -g '.....'='../../../..'
Then I can use 'cd ...'. Any ideas how to improve this situation?
It would be cool if it were possible to expand strings of dots
in every path without having to . I guess most of the stuff in the
list below is not possible yet, so you can consider individual item
to be enhancement requests.
1) '.....................' becomes 'cd ../../../<and so on>'.
It should be possible to configure this without dozens of alias
2) 'cd .....' becomes 'cd ../../../..' (also without many aliases)
Already possible if you don't mind the many aliases you need.
You can't have (1) and (2) at the same time
3) '.../bin/zsh' becomes '../../bin/zsh'
could be implemented as an enhancement to global aliases
4) '/usr/local/bin/.../bin' becomes '/usr/local/bin/../../bin'
could be implemented as an enhancement to global aliases too
Furthermore it would be nice if you didn't have to type a slash
before and after the dots in a path (on a german keyboard you
have to press shift-7 to get a slash which is a bit unwiedly).
5) '..bin' becomed '../bin' and 'bin..man' becomes 'bin/../man'
of course you'd need some form of escaping for file names that
All of this could be done with new options of the alias command
and some changes in alias expansion I think:
-p: ('p' stands for 'parameter alias'; e.g. 'alias -p foo=bar')
Defines an alias that is only expanded in positional parameters,
but not if it occurs in command position.
-R: ('R' stands for 'REGEXP'; e.g. alias '(.*)\.\.\.(.*)'='\1../..\2')
Allow (extended) regular expression syntax in alias definitions
With these two, all of the above could be implemented:
# recursively translates ... to ../.. anywhere in a string
alias -g -R '(.*)\.\.\.(.*)'='\1../..\2'
# these two add a / before and after the .. if necessary
alias -g -R '(.*[^/.])..'='\1/..'
alias -g -R '..(.*[^/.])'='../\1'
# and finally prepend 'cd'
alias -R '\.\.(.*)'='cd ..\1'
Please reply to me directly, I'm not subscribed to the list.
Dominik Vogt, dominik.vogt@xxxxxx
Messages sorted by: