Improve filesystem type completions.

This commit is contained in:
Ville Skyttä 2010-04-21 19:07:17 +03:00
parent 65fd4f1798
commit e270eb18e3
6 changed files with 52 additions and 8 deletions

View File

@ -25,10 +25,10 @@ bash-completion (2.x)
* Apply cardctl completion to pccardctl too.
* Apply pine completion to alpine too.
* Remove many unnecessary short option completions where long ones exist.
* Improve chsh, chgrp, chown, configure, cvs, gkrellm, gzip, iconv, lftp,
look, make, man, mdadm, modprobe, mplayer, mysqladmin, perldoc, rsync,
screen, service, scp, ssh, sshfs, update-alternatives, vncviewer, wget,
yp-tools, and general hostname completions.
* Improve chsh, chgrp, chown, configure, cvs, find, gkrellm, gzip, iconv,
lftp, look, make, man, mdadm, modprobe, mount, mplayer, mysqladmin,
perldoc, rsync, screen, service, scp, ssh, sshfs, update-alternatives,
vncviewer, wget, yp-tools, and general hostname completions.
* Add abook and wtf completion, based on work by Raphaël Droz.
* Add cvsps, dragon, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake,
pack200, unpack200, pbzip2, pbunzip2, pbzcat, pigz and unpigz completions.

View File

@ -950,6 +950,29 @@ _shells()
-- "$cur" ) )
}
# This function completes on valid filesystem types
#
_fstypes()
{
local fss
if [ -e /proc/filesystems ] ; then
# Linux
fss="$( cut -d$'\t' -f2 /proc/filesystems )
$( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )"
else
# Generic
fss="$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null )
$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null )
$( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null )
$( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null )
$( [ -d /etc/fs ] && command ls /etc/fs )"
fi
[ -n "$fss" ] && \
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$fss" -- "$cur" ) )
}
# Get real command.
# - arg: $1 Command
# - stdout: Filename of command in PATH with possible symbolic links resolved.

View File

@ -22,10 +22,11 @@ _find()
return 0
;;
-fstype)
# this is highly non-portable
[ -e /proc/filesystems ] &&
COMPREPLY=( $( compgen -W "$( cut -d$'\t' -f2 /proc/filesystems )" \
-- "$cur" ) )
_fstypes
if [[ "$( uname -s )" == *BSD ]] ; then
COMPREPLY=( "${COMPREPLY[@]}" \
$( compgen -W 'local rdonly' -- "$cur" ) )
fi
return 0
;;
-gid)

View File

@ -82,6 +82,14 @@ _mount()
COMPREPLY=()
cur=`_get_cword ':'`
prev=`_get_pword ':'`
case $prev in
-t|--types)
_fstypes
return 0
;;
esac
[[ "$cur" == \\ ]] && cur="/"
if [[ "$cur" == *:* ]]; then

View File

@ -17,6 +17,12 @@ assert_complete_any "find "
sync_after_int
assert_complete_any "find -fstype "
sync_after_int
set options [list -amin -anewer -atime -cmin -cnewer -ctime -daystart -depth -empty -exec \
-false -fls -follow -fprint -fprint0 -fprintf -fstype -gid -group -help -ilname -iname \
-inum -ipath -iregex -iwholename -links -lname -ls -maxdepth -mindepth -mmin -mount \

View File

@ -44,6 +44,12 @@ assert_complete_any "mount "
sync_after_int
assert_complete_any "mount -t "
sync_after_int
set test "Check completing nfs mounts"
set expected [list /test/path /test/path2 /second/path]
set cmd "mount mocksrv:/"