1
# mount(8) completion -*- shell-script -*-
5
local cur prev words cword
6
_init_completion -n =: || return
11
# find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1
13
if [[ "$cur" == ?*,* ]]; then
18
COMPREPLY=( $(compgen -W 'auto adfs affs autofs btrfs cifs coda
19
cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs
20
iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc
21
qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf
22
ufs umsdos usbfs vfat xfs' -- "$cur") )
24
$split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} )
32
COMPREPLY=( $(compgen -W '{0..9}') )
37
COMPREPLY=( $( cd "/dev/disk/by-label/" 2>/dev/null || return; \
38
compgen -f -- "$cur" ) )
42
COMPREPLY=( $( cd "/dev/disk/by-uuid/" 2>/dev/null || return; \
43
compgen -f -- "$cur" ) )
47
# argument required but no completions available
51
local fstype=auto # default fstype
52
for (( i=${#words[@]}-1; i>0; i-- )); do
53
if [[ "${words[i]}" == -@(t|-types)* ]]; then
54
if [[ "${words[i]}" == *=* ]]; then
55
[[ "${words[i]}" == ?*,* ]] && break
56
fstype="${words[i]#-*=}"
58
[[ "${words[i+1]}" == ?*,* ]] && break
59
fstype="${words[i+1]}"
64
# no<fstype> is not a real fstype, reset to "auto"
65
[[ "$fstype" == no?* ]] && fstype=auto
67
if [[ "$cur" == ?*,* ]]; then
72
# no completion if $cur is opt=smth
73
[[ "$cur" == *=* ]] && return
75
COMPREPLY=( $(compgen -W 'loop async {,no}atime {,no}auto
76
{,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync
77
{,no}exec group {,no}iversion {,no}mand _netdev nofail
78
{,no}relatime {,no}strictatime {,no}suid owner remount ro rw
79
sync {,no}user users' -- "$cur") )
82
COMPREPLY+=( $(compgen -W 'uid= gid= {own,oth}mask=' -- \
86
COMPREPLY+=( $(compgen -W '{u,g}id= set{u,g}id= mode= protect
87
usemp verbose prefix= volume= reserved= root= bs=
88
{,no,usr,grp}quota' -- "$cur") )
91
COMPREPLY+=( $(compgen -W 'degraded subvol= subvolid= device=
92
nodatasum nodatacow nobarrier max_inline= alloc_start=
93
thread_pool= compress= compress-force= ssd noacl notreelog
94
flushoncommit metadata_ratio= {,no}space_cache clear_cache
95
user_subvol_rm_allowed autodefrag inode_cache' -- "$cur") )
98
COMPREPLY+=( $(compgen -W 'user= password= credentials= {u,g}id=
99
force{u,g}id port= servern= netbiosname= {file,dir}_mode=
100
ip= domain= guest iocharset ro rw {,no}setuids {,no,dyn}perm
101
directio {,no}mapchars {,no}intr hard soft noacl nocase sec=
102
nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size=
103
rwpidforward backup{u,g}id' -- "$cur") )
106
COMPREPLY+=( $(compgen -W '{,no}acl bsddf minixdf check= debug
107
errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota
108
nobh nouid32 oldalloc orlov res{u,g}id= sb=
109
{,no}user_xattr' -- "$cur") )
112
COMPREPLY+=( $(compgen -W 'journal= journal_dev= norecovery
113
noload data= barrier= commit=' -- "$cur") )
116
COMPREPLY+=( $(compgen -W 'journal_checksum journal_async_commit
117
nobarrier inode_readahead= stripe= {,no}delalloc abort
118
{max,min}_batch_time= journal_ioprio= {,no}auto_da_alloc
119
{,no}discard nouid32 resize {,no}block_validity
120
dioread_{,no}lock i_version' -- "$cur") )
122
msdos|umsdos|vfat|auto)
123
COMPREPLY+=( $(compgen -W 'blocksize= {u,g}id= {u,d,f}mask=
124
allow_utime= check= codepage= conv= cvf_format= cvf_option=
125
debug fat= iocharset= tz= quiet showexec sys_immutable flush
126
usefree {,no}dots dotsOK=' -- "$cur") )
129
COMPREPLY+=( $(compgen -W 'uni_xlate posix nonumtail utf8
130
shortname=' -- "$cur") )
133
COMPREPLY+=( $(compgen -W 'norock nojoliet check= {u,g}id= map=
134
mode= unhide block= conv= cruft session= sbsector=
135
iocharset= utf8' -- "$cur") )
138
COMPREPLY+=( $(compgen -W 'compr=' -- "$cur") )
141
COMPREPLY+=( $(compgen -W 'iocharset= resize= {,no}integrity
142
errors= {,no,usr,grp}quota' -- "$cur") )
145
COMPREPLY+=( $(compgen -W '{u,g}id= {u,f,d}mask= usermapping=
146
permissions inherit ro locale= force {,no}recover
147
ignore_case remove_hiberfile {,no,rel}atime show_sys_files
148
hide_{hid,dot}_files windows_names allow_other max_read=
149
silent no_def_opts streams_interface= user_xattr efs_raw
150
{,no}compression debug no_detach' -- "$cur") )
153
COMPREPLY+=( $(compgen -W '{u,g}id=' -- "$cur") )
156
COMPREPLY+=( $(compgen -W 'conv hash= {,no_un}hashed_relocation
157
noborder nolog notail replayonly resize= user_xattr acl
158
barrier=' -- "$cur") )
161
COMPREPLY+=( $(compgen -W 'size= nr_blocks= nr_inodes= mode=
162
{u,g}id= mpol=' -- "$cur") )
165
COMPREPLY+=( $(compgen -W '{u,g}id= umask= unhide undelete
166
nostrict iocharset bs= novrs session= anchor= volume=
167
partition= lastblock= fileset= rootdir=' -- "$cur") )
170
COMPREPLY+=( $(compgen -W 'dev{u,g}id= devmode= bus{u,g}id=
171
busmode= list{u,g}id= listmode=' -- "$cur") )
174
COMPREPLY+=( $(compgen -W 'allocsize= {,no}attr2 barrier dmapi
175
{,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep inode64
176
{,no}largeio logbufs= logbsize= logdev= rtdev= mtpt= noalign
177
noatime norecovery nouuid osyncisosync {u,g,p}qnoenforce
178
{,u,usr,g,grp,p,prj}quota sunit= swidth= swalloc' \
182
# COMP_WORDBREAKS is a real pain in the ass
183
prev="${prev##*[$COMP_WORDBREAKS]}"
184
$split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} )
185
[[ $COMPREPLY == *= ]] && compopt -o nospace
190
if [[ "$cur" == -* ]]; then
191
COMPREPLY=( $( compgen -W '--version --help --verbose --all --fork
192
--fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s
193
--read-only --rw -L -U --types --test-opts --options --bind --rbind
194
--move' -- "$cur" ) )
195
[[ $COMPREPLY ]] && return
198
[[ "$cur" == \\ ]] && cur="/"
202
if [[ "$cur" == *:* ]]; then
203
for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
204
[[ -x $sm ]] || continue
205
COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \
206
awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) )
211
if [[ "$cur" == //* ]]; then
214
if [[ -n $host ]]; then
215
COMPREPLY=( $( compgen -P "//$host" -W \
216
"$( smbclient -d 0 -NL $host 2>/dev/null |
217
sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' |
218
sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \
219
-- "${cur#//$host}" ) )
225
complete -F _mount mount
227
# ex: ts=4 sw=4 et filetype=sh