Last active
December 18, 2015 09:08
-
-
Save dburger/5758862 to your computer and use it in GitHub Desktop.
bash shell function to add chrome profile name completion to a "gchrome" command.
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
function _gchrome_profile() { | |
local IFS=$'\n' | |
local param=${COMP_WORDS[COMP_CWORD]} | |
local profiles="" | |
local preffile | |
for preffile in ~/.config/google-chrome/{Default,Profile*}/Preferences; do | |
# The profile name appears to always be the last "name:" in the json | |
# of the Preferences file. Yes, fragile, but appears to work for now. | |
local name=$(grep \"name\" "$preffile" | tail -1 | sed -e 's/.*"\([^"]*\)",\?$/\1/') | |
profiles="$profiles | |
$name" | |
done | |
COMPREPLY=( $(compgen -W "$profiles" "$param") ) | |
} | |
complete -F _gchrome_profile gchrome |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment