-
-
Save kingtosh/c20930ed4fa042f461b0b389fe42fa28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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