* cd directory completion? @ 1999-08-23 13:22 Dominik Vogt 1999-08-23 13:35 ` Andre Pang 0 siblings, 1 reply; 12+ messages in thread From: Dominik Vogt @ 1999-08-23 13:22 UTC (permalink / raw) To: zsh-users I'd like to have cd complete directory names as well as symlinks that point to directories (zsh-3.0.6). Is there a way to do this without writing a completion function? (And I don't want to fiddle with any 'chase symlink' setting there may be - I like them the way they are). I couldn't find anything appropriate in the man page. If it's not possible without a function, has anybody written one and can send it to me? Bye Dominik ^_^ P.S.: please CC me on replies, I'm not on the list. -- Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS Herrenberger Str.130, 71034 Boeblingen, Germany phone: 07031/14-4596, fax: 07031/14-3883, dominik_vogt@hp.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: cd directory completion? 1999-08-23 13:22 cd directory completion? Dominik Vogt @ 1999-08-23 13:35 ` Andre Pang 1999-08-23 14:07 ` Dominik Vogt 0 siblings, 1 reply; 12+ messages in thread From: Andre Pang @ 1999-08-23 13:35 UTC (permalink / raw) To: Dominik Vogt; +Cc: zsh-users On Mon, Aug 23, 1999 at 03:22:19PM +0200, Dominik Vogt wrote: > I'd like to have cd complete directory names as well as > symlinks that point to directories (zsh-3.0.6). Is there > a way to do this without writing a completion function? > (And I don't want to fiddle with any 'chase symlink' setting > there may be - I like them the way they are). I couldn't > find anything appropriate in the man page. If it's not > possible without a function, has anybody written one and > can send it to me? I dunno if this is any 'good' (from a technical zsh perspective), but here's mine for 3.1.5. May (not) work on 3.0.6. Also have provided other (really) simple ones which I've used. compctl -g '*(-/) .*(-/)' cd # what you want compctl -g '*(/) .*(/)' rmdir compctl -j -P % kill compctl -j -P % fg compctl -j -P % bg compctl -u w compctl -m whence compctl -c which compctl -c man compctl -u who Flame away if any of them suck :). -- __/\___/\_/\____/\____/\ Andre Pang / /__ / \_ \_ __) ( : / (__: ) | | _)_ ozone@ihug.com.au, andrep@cse.unsw.edu.au \___( ______/|__;__|_____| http://www.mindflux.com.au/ozone/ \/ - #ozone mobile ph#: 0411-882299 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: cd directory completion? 1999-08-23 13:35 ` Andre Pang @ 1999-08-23 14:07 ` Dominik Vogt 1999-08-23 15:03 ` Sweth Chandramouli 1999-08-25 4:32 ` cd directory completion? Bek Oberin 0 siblings, 2 replies; 12+ messages in thread From: Dominik Vogt @ 1999-08-23 14:07 UTC (permalink / raw) To: ozone, zsh-users On Mon, Aug 23, 1999 at 11:35:51PM +1000, ozone@ihug.com.au wrote: > On Mon, Aug 23, 1999 at 03:22:19PM +0200, Dominik Vogt wrote: > > > I'd like to have cd complete directory names as well as > > symlinks that point to directories (zsh-3.0.6). Is there > > a way to do this without writing a completion function? > > (And I don't want to fiddle with any 'chase symlink' setting > > there may be - I like them the way they are). I couldn't > > find anything appropriate in the man page. If it's not > > possible without a function, has anybody written one and > > can send it to me? > > I dunno if this is any 'good' (from a technical zsh perspective), but > here's mine for 3.1.5. May (not) work on 3.0.6. Also have provided other ^^^^^ *does* work on 3.0.6. > (really) simple ones which I've used. > > compctl -g '*(-/) .*(-/)' cd # what you want > compctl -g '*(/) .*(/)' rmdir > compctl -j -P % kill > compctl -j -P % fg > compctl -j -P % bg > compctl -u w > compctl -m whence > compctl -c which > compctl -c man > compctl -u who Looks pretty much like the stuff I use. In the end all compctl configs end up the same :-) But I wonder why you use whence and where at all (do you?). It's so much easier to just type # ls =filename and hit TAB :-)) I'm especially fond of my man page completion. Bye Dominik ^_^ -- Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS Herrenberger Str.130, 71034 Boeblingen, Germany phone: 07031/14-4596, fax: 07031/14-3883, dominik_vogt@hp.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: cd directory completion? 1999-08-23 14:07 ` Dominik Vogt @ 1999-08-23 15:03 ` Sweth Chandramouli 1999-08-25 13:46 ` listing all executables matching 'foo' Sven Guckes 1999-08-25 4:32 ` cd directory completion? Bek Oberin 1 sibling, 1 reply; 12+ messages in thread From: Sweth Chandramouli @ 1999-08-23 15:03 UTC (permalink / raw) To: zsh-users On Mon, Aug 23, 1999 at 04:07:16PM +0200, Dominik Vogt wrote: > > Looks pretty much like the stuff I use. In the end all compctl > configs end up the same :-) But I wonder why you use whence > and where at all (do you?). It's so much easier to just type > > # ls =filename > > and hit TAB :-)) yes, but that returns totally different information, especially in zsh, where which and type are just cosmetic variants of whence--all three thus go through the entire process of command lookup, including functions and builtins. the =<command> syntax just does alias expansion and executable searching via path, while (k/c)sh-style which just does executable searching; these two also thus do not provide any information about whether some command is a function or a builtin, and don't expand aliases/functions/ builtins so that you can quickly see their definition without looking at source files, etc. (i personally think the zsh versions of those commands should mirror the equivalent ksh tools in behaviour (it's sometimes very useful to only do executable searching, for example), but since /bin/which and /bin/type exist and act like the ksh versions, i've just aliased which and type to their executable versions. (of course, then you have issues figuring out just what `alias which=/bin/which ; alias which=$(whence -a which | head -1)' does, but that's what makes playing with your shell fun.)) -- sweth. -- Sweth Chandramouli ; <sweth@gwu.edu> <a href="http://astaroth.nit.gwu.edu/resume/">Will Work For Food.</a> <a href="http://astaroth.nit.gwu.edu/~sweth/disc.html">*</a> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: listing all executables matching 'foo' 1999-08-23 15:03 ` Sweth Chandramouli @ 1999-08-25 13:46 ` Sven Guckes 1999-08-25 14:22 ` Hubert Canon ` (2 more replies) 0 siblings, 3 replies; 12+ messages in thread From: Sven Guckes @ 1999-08-25 13:46 UTC (permalink / raw) To: zsh-users * On Mon, Aug 23, 1999 at 04:07:16PM +0200, Dominik Vogt wrote: > # ls =filename > and hit TAB :-)) * Sweth Chandramouli (sweth@gwu.edu) [990823 15:03]: > yes, but that returns totally different information, especially in zsh, > [...] > (of course, then you have issues figuring out just what > `alias which=/bin/which ; alias which=$(whence -a which | head -1)' > does, but that's what makes playing with your shell fun.)) Apropos: _listall () { if [[ $# = 0 ]] then echo "Usage: $0 program" echo "Example: $0 zsh" echo "Lists all occurrences of program in the current PATH." else for program in `which -a $1` do ls -lL $program done fi } Comments? Sven -- Sven Guckes guckes@math.fu-berlin.de using zsh-3.0.5 [961218] ZSH HomePage: http://www.zsh.org | Latest version: zsh-3.1.5 [981030] ZSH Pages: http://www.math.fu-berlin.de/~guckes/zsh/ Tips and tricks ZSH Tips: http://www.math.fu-berlin.de/~guckes/zsh/tips.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: listing all executables matching 'foo' 1999-08-25 13:46 ` listing all executables matching 'foo' Sven Guckes @ 1999-08-25 14:22 ` Hubert Canon 1999-08-25 14:53 ` Sven Guckes 1999-08-26 3:59 ` James Cribb 1999-08-26 16:24 ` Sweth Chandramouli 2 siblings, 1 reply; 12+ messages in thread From: Hubert Canon @ 1999-08-25 14:22 UTC (permalink / raw) To: zsh-users Sven Guckes écrivait : > Apropos: > > _listall () { > if [[ $# = 0 ]] > then > echo "Usage: $0 program" > echo "Example: $0 zsh" > echo "Lists all occurrences of program in the current PATH." > else > for program in `which -a $1` > do > ls -lL $program > done > fi > } > > Comments? Gives strange things with aliases and functions : % which -a which which: aliased to which -a which: shell built-in command /bin/which /usr/bin/which % _listall which ls: which:: No such file or directory ls: aliased: No such file or directory ls: to: No such file or directory ls: which: No such file or directory total 4 drwx------ 2 canon pampa 512 Aug 25 16:21 . drwx------ 5 canon pampa 2560 Aug 25 16:21 .. ls: which:: No such file or directory ls: shell: No such file or directory ls: built-in: No such file or directory ls: command: No such file or directory -r-xr-xr-x 1 bin bin 1155 Oct 25 1995 /bin/which -r-xr-xr-x 1 bin bin 1155 Oct 25 1995 /usr/bin/which -- Hubert Canon ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: listing all executables matching 'foo' 1999-08-25 14:22 ` Hubert Canon @ 1999-08-25 14:53 ` Sven Guckes 1999-08-25 14:59 ` Paul Lew 0 siblings, 1 reply; 12+ messages in thread From: Sven Guckes @ 1999-08-25 14:53 UTC (permalink / raw) To: zsh-users * Sven Guckes écrivait : > Comments? * Hubert Canon (Hubert.Canon@irisa.fr) [990825 14:22]: > Gives strange things with aliases and functions : True. So, how to take care of these? "if type(foo)==alias"? Sven ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: listing all executables matching 'foo' 1999-08-25 14:53 ` Sven Guckes @ 1999-08-25 14:59 ` Paul Lew 0 siblings, 0 replies; 12+ messages in thread From: Paul Lew @ 1999-08-25 14:59 UTC (permalink / raw) To: Sven Guckes; +Cc: zsh-users >>>>> "Sven" == Sven Guckes <guckes@math.fu-berlin.de> writes: Sven> * Hubert Canon (Hubert.Canon@irisa.fr) [990825 14:22]: >> Gives strange things with aliases and functions : Sven> True. So, how to take care of these? Sven> "if type(foo)==alias"? Just add -p to which command, which -ap instead which -a. I often use: ls -l $(which -ap zsh) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: listing all executables matching 'foo' 1999-08-25 13:46 ` listing all executables matching 'foo' Sven Guckes 1999-08-25 14:22 ` Hubert Canon @ 1999-08-26 3:59 ` James Cribb 1999-08-26 12:27 ` Sven Guckes 1999-08-26 16:24 ` Sweth Chandramouli 2 siblings, 1 reply; 12+ messages in thread From: James Cribb @ 1999-08-26 3:59 UTC (permalink / raw) To: zsh-users Sven Guckes wrote: > > _listall () { > if [[ $# = 0 ]] > then > echo "Usage: $0 program" > echo "Example: $0 zsh" > echo "Lists all occurrences of program in the current PATH." > else > for program in `which -a $1` > do > ls -lL $program > done > fi > } > > Comments? I often use "ls -l $^path/foo 2>/dev/null". ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: listing all executables matching 'foo' 1999-08-26 3:59 ` James Cribb @ 1999-08-26 12:27 ` Sven Guckes 0 siblings, 0 replies; 12+ messages in thread From: Sven Guckes @ 1999-08-26 12:27 UTC (permalink / raw) To: zsh-users * James Cribb (jamesc@zip.com.au) [990826 04:01]: > I often use "ls -l $^path/foo 2>/dev/null". Redirecting error messages is for wimps. ;-) Sven ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: listing all executables matching 'foo' 1999-08-25 13:46 ` listing all executables matching 'foo' Sven Guckes 1999-08-25 14:22 ` Hubert Canon 1999-08-26 3:59 ` James Cribb @ 1999-08-26 16:24 ` Sweth Chandramouli 2 siblings, 0 replies; 12+ messages in thread From: Sweth Chandramouli @ 1999-08-26 16:24 UTC (permalink / raw) To: zsh-users On Wed, Aug 25, 1999 at 03:46:32PM +0200, Sven Guckes wrote: > _listall () { > if [[ $# = 0 ]] > then > echo "Usage: $0 program" > echo "Example: $0 zsh" > echo "Lists all occurrences of program in the current PATH." > else > for program in `which -a $1` > do > ls -lL $program > done > fi > } > > Comments? i've got a similar function i use called lall. it figures out whether each command returned by whence -a is an executable, an alias, a function, or a builtin, and then returns more info based on that decision--an ls for executables, a whence -f for functions, or an ls of the core command of the expanded alias for aliases. it's actually pretty cool, if i do say so myself: (cj952583-b)~: lall ll ll is an alias for ls -lF: ls is /bin/ls: -r-xr-xr-x 1 bin bin 18120 Oct 6 1998 /bin/ls ls is /usr/bin/ls: -r-xr-xr-x 1 bin bin 18120 Oct 6 1998 /usr/bin/ls ls is /usr/xpg4/bin/ls: -r-xr-xr-x 1 bin bin 18128 Sep 1 1998 /usr/xpg4/bin/ls ls is /usr/ucb/ls: -rwxr-xr-x 1 bin bin 13776 Sep 1 1998 /usr/ucb/ls (cj952583-b)~: lall cd cd is a shell builtin cd is /bin/cd: -r-xr-xr-x 17 bin bin 131 Oct 6 1998 /bin/cd cd is /usr/bin/cd: -r-xr-xr-x 17 bin bin 131 Oct 6 1998 /usr/bin/cd (cj952583-b)~: lall xbuffy xbuffy is a shell function: undefined xbuffy () { } xbuffy is /usr/local/bin/xbuffy: lrwxrwxrwx 1 root other 22 Jul 21 16:18 /usr/local/bin/xbuffy -> /opt/xbuffy/bin/xbuffy (cj952583-b)~: lall chunk chunk is a shell function: chunk () { local LENGTH=$(( ${LINES:-20}/2-2 )) local START=${LENGTH} if [[ ${1#-} != ${1} ]] then START=${(R)1#-} shift fi tail -${START} ${@} | head -${LENGTH} } (cj952583-b)~: cat .zfunc/lall #!/usr/local/bin/zsh -f # lall -- function to List ALL commands that might be run given the # current environment, and give info about them if possible. lall () { # extremely verbose whence; lall is just a wrapper to iterate it across # the positional params. v_whence () { for CMD in ${(f)"$(builtin whence -av ${1})"} ; do # this matches any executables found and does an ls on them. # the (|.) is the zsh version of ?(.), it seems; i use it to # match things in the current directory, too, since i am one of # those unsecure folks with CWD (.) at the end of my path. if [[ ${CMD%%(|.)/*} != ${CMD} ]] ; then builtin echo "${CMD}:" builtin echo " $(ls -l ${(M)CMD%%(|.)/*})" # this matches functions and gives their expansion. elif [[ ${CMD%%function} != ${CMD} ]] ; then builtin echo "${CMD}:" # using sed would be much cleaner, but i like zsh-only functions. # would that ls were a builtin... for LINE in ${(f)"$(builtin whence -f ${1})"} ; do builtin echo " ${LINE}" done # okay, so this is a bit excessive. if it's an alias, we actually # say so and then start over by running v_whence on the first # token of the expanded alias. (some days i scare myself.) elif [[ ${CMD##*alias for } != ${CMD} ]] ; then builtin echo "${CMD}:" for LINE in ${(f)"$(v_whence ${${CMD##*alias for }%% *})"} ; do builtin echo " ${LINE}" done # if it still isn't matched, it's a shell builtin. else builtin echo "${CMD}" fi done } for WORD in "${@}" ; do v_whence ${WORD} done } other than the hideous "for LINE in ..." kludge, of which i've grown unreasonably fond, any suggestions for improvement? i thought about doing a whence -avf initially to obviate the need for it later if a function was matched, but the formatting became much more convoluted then, so i gave up on it. i've also thought about making it accept a -v flag, to make it even more verbose--maybe run file on the executables as well, or something like that. -- sweth. -- Sweth Chandramouli ; <sweth@gwu.edu> <a href="http://astaroth.nit.gwu.edu/resume/">Will Work For Food.</a> <a href="http://astaroth.nit.gwu.edu/~sweth/disc.html">*</a> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: cd directory completion? 1999-08-23 14:07 ` Dominik Vogt 1999-08-23 15:03 ` Sweth Chandramouli @ 1999-08-25 4:32 ` Bek Oberin 1 sibling, 0 replies; 12+ messages in thread From: Bek Oberin @ 1999-08-25 4:32 UTC (permalink / raw) To: Dominik Vogt; +Cc: ozone, zsh-users Dominik Vogt wrote: > configs end up the same :-) But I wonder why you use whence > and where at all (do you?). It's so much easier to just type > # ls =filename > and hit TAB :-)) Wow, I never heard of that one! Thanks :) bekj *mutter*newtricks*yay*mutter* -- : --Hacker-Neophile-Eclectic-Geek-Grrl-Queer-Disabled-Boychick-- : gossamer@tertius.net.au http://www.tertius.net.au/~gossamer/ : Good people can't out-think evil, cause evil thinks of things : good folks can't think of. -- Orson Scott Card, Homebody ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~1999-08-26 16:25 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1999-08-23 13:22 cd directory completion? Dominik Vogt 1999-08-23 13:35 ` Andre Pang 1999-08-23 14:07 ` Dominik Vogt 1999-08-23 15:03 ` Sweth Chandramouli 1999-08-25 13:46 ` listing all executables matching 'foo' Sven Guckes 1999-08-25 14:22 ` Hubert Canon 1999-08-25 14:53 ` Sven Guckes 1999-08-25 14:59 ` Paul Lew 1999-08-26 3:59 ` James Cribb 1999-08-26 12:27 ` Sven Guckes 1999-08-26 16:24 ` Sweth Chandramouli 1999-08-25 4:32 ` cd directory completion? Bek Oberin
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).