Skip to content

Instantly share code, notes, and snippets.

@mrflip
Created August 29, 2008 14:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrflip/7983 to your computer and use it in GitHub Desktop.
Save mrflip/7983 to your computer and use it in GitHub Desktop.
Tab complete the 'open' command in OSX
# 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'
)" -- $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