Index: tools/bash-completion |
diff --git a/tools/bash-completion b/tools/bash-completion |
index 6a1b89a964e842913917163d4d963cf318d33bb8..b0f13d404a547c4b009ea584a4bb8e36c882515e 100644 |
--- a/tools/bash-completion |
+++ b/tools/bash-completion |
@@ -5,17 +5,30 @@ |
# Flag completion rule for bash. |
# To load in your shell, "source path/to/this/file". |
-chrome_source=$(readlink -f $(dirname $BASH_SOURCE)/..) |
+chrome_source=$(dirname $BASH_SOURCE)/.. |
+if [ $(uname) = "Darwin" ] |
+then |
+ chrome_source=$(python -c 'import os,sys;print os.path.realpath(sys.argv[1])'\ |
+ $chrome_source) |
Evan Martin
2012/02/17 20:23:17
Simpler:
chrome_source=$((cd $chrome_source && pwd
groby-ooo-7-16
2012/02/17 22:19:28
Surely you only meant one level of parens :)
On 2
|
+ sed_expr='s/^[^/]*"\([^" /]*\)".*/--\1/p' |
Evan Martin
2012/02/17 20:23:17
Why is this different between Darwin and not?
groby-ooo-7-16
2012/02/17 22:19:28
Because Darwin doesn't support \+. And if I'd read
|
+else |
+ chrome_source=$(readlink -f $chrome_source) |
+ sed_expr='s/^[^/]*"\([^" /]\+\)".*/--\1/p' |
+fi |
_chrome_flag() { |
local cur targets |
cur="${COMP_WORDS[COMP_CWORD]}" |
targets=$(cd $chrome_source; \ |
git ls-files '*switches*' | \ |
- xargs sed -ne 's/^[^/]*"\([^" /]\+\)".*/--\1/p') |
+ xargs sed -ne "$sed_expr") |
COMPREPLY=($(compgen -W "$targets" -- "$cur")) |
return 0 |
} |
complete -F _chrome_flag google-chrome |
complete -F _chrome_flag chrome |
+if [ $(uname) = "Darwin" ] |
+then |
+ complete -F _chrome_flag Chromium |
+fi |