photo
Jordan Sissel
geek

Tue, 26 Apr 2005

zsh compctl

Got bored after doing some homework tonight and added a few more completions to my zsh config. The top two are yanked from petef's zshrc
compctl -g '/u9/psionic/Mail/*(/:t)' -P '+' folder
compctl -g '/var/db/pkg/*(/:t)' pkg_delete pkg_info
compctl -g "/tmp/screens/S-${USER}/*(p:t)" screen
compctl -g "*(-/D)" + -g "*.class(.:r)" java
What do they do? (Listed in order)
  • for the program 'folder' complete to any directory in /u9/psionic/Mail/ and drop the path above it (like basename(1)). Also prefix it with a '+' character.
    fury(~) [1] !127! % folder +TAB
    drafts      exec        inbox       lists       old         rtp         spam        
    duplicates  foo         jason       main        outbox      security    work        
    
  • complete package names under freebsd for pkg_delete and pkg_info
    nightfall(~/foo/project) [1021] % pkg_info TAB
    ORBit2-2.12.1_1               isc-dhcp3-server-3.0.1.r14_6  png-1.2.6
    adns-1.0_1                    jad-1.5.8c                    portupgrade-20041226_1
    aspell-0.60.2                 jpeg-6b_3                     ruby-1.8.2_3
    ... the list goes on ...
    
  • complete screen sessions
    nightfall(~/foo/project) [1022] !1! % screen -x TAB
    11950.ttyp6.nightfall  16783.ttyp2.nightfall  16852.ttypa.nightfall  709.ttyp8.nightfall
    16146.ttypn.nightfall  16801.ttyp4.nightfall  17336.ttyp0.nightfall  741.ttypc.nightfall
    
  • complete java class names without the '.class' extension
    nightfall(~/foo/project/os1/step1) [1024] % java sys/TAB
    ExitCode  Kernel    Panic
    

Comments: 1 (view comments)
Tags:
Permalink: /geekery/160
posted at: 05:41


1 responses to 'zsh compctl'

Mike posted at Mon Apr 16 11:06:29 2007...
Funny. Found this post through searching on google for zsh completion.

Not sure why, but when using `sudo` I cannot get any commands to complete files/folders besides `ls`. Using sudo with commands like chown, chmod, vi, etc won't allow me to tab complete any files/folders. It will, however, complete more commands. Something like "sudo vi l[TAB]" will result in a list of all commands starting with "l" as opposed to any files/folders that start with "l" in the pwd.

I was originally using all compctl to do autocomplete and then moved to the new completion system. Any ideas on how to get that to work?


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional, if you want me to be able to email you back)
URL (also optional)
Comment:


Search this site

Navigation

Metadata

Home About Resume My Code (SVN)

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials

Tag Cloud

Calendar

< April 2005 >
SuMoTuWeThFrSa
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati