Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
diskutil_options="activity
appleRAID
coreStorage
disableJournal
disableOwnership
eject
enableJournal
enableOwnership
eraseDisk
eraseOptical
eraseVolume
info
list
listFilesystems
mergePartitions
mount
mountDisk
moveJournal
partitionDisk
randomDisk
reformat
rename [Volume]
repairDisk
repairVolume
resizeVolume
secureErase
splitPartition
umount
unmount
unmountDisk
verifyDisk
verifyVolume
zeroDisk
"
# echo "$options" | awk '{print $1 }'
### 引数をecho するだけの簡単な関数。
### 補完関数。
_diskutil(){
arg0="${COMP_WORDS[0]}"
arg1="${COMP_WORDS[1]}"
list=$( echo "$diskutil_options" | awk '{print $1}')
if [ $arg1 ] ; then
for sub in $list ; do
if [ $arg1 = $sub ] ; then
list=$(diskutil list | /usr/bin/grep /dev/disk | awk '{ print $1 }')
COMPREPLY=( $(compgen -W "$list" ${COMP_WORDS[COMP_CWORD]} ) )
diskutil list
return;
fi
done
fi
COMPREPLY=( $(compgen -W "$list" ${COMP_WORDS[COMP_CWORD]} ) )
}
complete -F _diskutil diskutil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment