-
-
Save aik099/4482856 to your computer and use it in GitHub Desktop.
Bash completion for "open -a" command on Mac. Changes from original script:
* no need to enclose app names, that have spaces in them (e.g. "Sublime Text 2") in double quotes to get auto-complete
* app names lowercased for auto-complete, which allows to use "open -a subl" instead of "open -a Subl"
This file contains hidden or 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
# http://woss.name/2005/09/06/bash-completion-for-mac-os-x-open/ | |
if [ "`uname`" = "Darwin" ]; then | |
_open() { | |
local cur prev | |
COMPREPLY=() | |
cur=${COMP_WORDS[COMP_CWORD]} | |
prev=${COMP_WORDS[COMP_CWORD-1]} | |
if [ "${prev}" = -a ]; then | |
local IFS=$'\n' | |
COMPREPLY=( $( | |
compgen -W "$( | |
/bin/ls -d1 /Applications/*/*.app /Applications/*.app | \ | |
sed 's|^.*/\([^/]*\)\.app.*|\1|;s/\ /\\ /g' | \ | |
sed 's/ /\\ /g' | \ | |
awk '{ print tolower($0) }' | |
)" -- $cur) | |
) | |
return 0 | |
fi | |
} | |
complete -F _open -o default open | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment