2

I use zsh with zim, which is generally excellent. Ideally, I'd want to umount's tab completion to only suggest items in /run/media/$USER. In the following example, this is a single volume named L_drive.

$ cd /run/media/sparhawk $ ls L_drive $ umount <Tab> -- device label -- binfmt_misc debugfs fusectl mqueue run systemd-1 cgroup dev gvfsd-fuse proc securityfs tmpfs configfs devpts hugetlbfs pstore sys -- device path -- /dev/sda2 /dev/sdb5 /dev/sdb6 /dev/sdc1 -- mount point -- / /run/media/sparhawk/L_drive /sys/fs/cgroup/pids /dev /run/user/1000 /sys/fs/cgroup/systemd /dev/hugepages /run/user/1000/gvfs /sys/fs/fuse/connections /dev/mqueue /sys /sys/fs/pstore /dev/pts /sys/fs/cgroup /sys/kernel/config /dev/shm /sys/fs/cgroup/blkio /sys/kernel/debug /HDD /sys/fs/cgroup/cpu,cpuacct /sys/kernel/security /home /sys/fs/cgroup/cpuset /tmp L_drive /sys/fs/cgroup/devices /var/cache /proc /sys/fs/cgroup/freezer /var/log /proc/sys/fs/binfmt_misc /sys/fs/cgroup/memory /var/tmp /run /sys/fs/cgroup/net_cls 

There is a lot of stuff there that I'd never want to tab complete. I'd like to remove all these suggestions, and only leave tab completion for the absolute path /run/media/sparhawk/L_drive.

FWIW zim has the following bug where the relative path is not found after typing a letter.

$ umount L<Tab> -- no matches found -- 

but assuming I can remove all the other suggestions, leaving only the absolute path in /run/media/$USER/*, then this bug is moot.

1 Answer 1

2

You can use the ignored-patterns style to exclude some completions.

zstyle ':completion:*:umount:*' ignored-patterns "^/run/media/$USER/*" 

Under the default settings, you can still get completion for ignored patterns if there is no non-ignored candidate.

(This answer is for plain zsh using the compinit completion system. It's possible, but unlikely, that zim somehow causes it not to work.)

1
  • Brilliant! Thank you! (There was a small typo that had to be fixed for it to work.) Commented Oct 24, 2016 at 0:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.