zsh-users
 help / color / mirror / code / Atom feed
From: Dominik Vogt <dominik.vogt@gmx.de>
To: zsh-users@sunsite.auc.dk
Subject: '...' in path names?
Date: Tue, 13 Jun 2000 17:54:17 +0200	[thread overview]
Message-ID: <20000613175417.A18345@gmx.de> (raw)

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
     lines
  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
     contain '..'.

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.

Bye

Dominik ^_^

--
Dominik Vogt, dominik.vogt@gmx.de
Reply-To: dominik.vogt@gmx.de


             reply	other threads:[~2000-06-14 18:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-13 15:54 Dominik Vogt [this message]
2000-06-15  0:25 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000613175417.A18345@gmx.de \
    --to=dominik.vogt@gmx.de \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).