Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

completion for (u)mount



I just hacked up comletion for mount and umount on Linux. I figured some
completion fanatics might like it.


	Stefan

comp_fsmount () {
    local tmp; if [[ $UID = 0 ]]; then tmp=""; else tmp="user"; fi
    sed -n -e "s|^[^# 	][^ 	]*[ 	][ 	]*\(/[^ 	]*\)[
].*$tmp.*|\1|p" /etc/fstab	# beware the tabs
}
comp_nfsmount () {
    local cmd args host
    read -Ac cmd; read -cn where
    host=${${cmd[$where]}%%:*}
    reply=("${(@f)$(showmount -e $host | sed -n -e "s|^/\([^ ]*\) .*|$host:/\1|p")}")
}
compctl -s '$(mount | \
	      sed -e "s/^[^ ]* on \\([^ ]*\\) type.*/\\1/"'"$(
	      if [[ ! $UID = 0 ]]; then
		  echo ' | egrep "^${(j:|:)$(comp_fsmount)}\$"'
	      fi)"')' umount
compctl -s '$(comp_fsmount)' + \
	-x 'S[/]' -f -- + \
	-x 'C[0,*:*]' -K comp_nfsmount -- + \
	-s '$(< /etc/hosts)' \
	mount



Messages sorted by: Reverse Date, Date, Thread, Author