bash - Adding Google Chrome to UNIX $PATH -
i got entangled unix file system , playing around terminal. noticed changed $path variable, running "google chrome", executable opening chrome window, gives me error message of
-bash: google chrome: command not found
here's context: google installed on /applications/google chrome.app/contents/macos executable called "google chrome" (i know because when type
/applications/google\ chrome.app/contents/macos/google\ chrome
a new chrome window pops out error message saying
[12838:35843:0822/170630.283203:error:browser_gpu_channel_host_factory.cc(103)] failed launch gpu process.
so i'm pretty sure executable running program)
then did little digging on $path variable supposed maintain searching path of find executables everytime type "command" (or exe doesnt matter). therefore, went ~ , find file called .bash_profile $path edited , stored , append file:
path="/applications/google\ chrome.app/contents/macos:${path}" export path
then source ~/.bash_profile , echo $path indeed directory containing chrome executable inserted part of $path follow:
> echo $path /applications/google\ chrome.app/contents/macos:/library/frameworks/python.framework/versions/3.6/bin: ...
then when type google\ chrome, system responds "command not found". went further more whereis google\ chrome , google\ chrome, yet got no response forces me believe google chrome not among executing path.
here's question, did wrong when trying edit $path make chrome easier access? because way understand $path wrong? or because miss tiny details? far know, should have chrome running other applications python , cassandra same $path edit didn't. please share precious insights me on topic. time , effort appreciated :)
what did wrong putting backslash variable literal; has shell trying find directory backslash in name. (because backslash present in output of echo
, know ended in final variable, rather being recognized meaningless sequence , discarded).
inside quotes, space known literal, there's no point additional backslash;
path="/applications/google chrome.app/contents/macos:$path"
...will suffice. (there's no need explicitly export
: updating shell variable named identically preexisting environment variable automatically alter latter).
by way -- if want define shell function can call chrome http://example.com/
, might like:
chrome() { '/applications/google chrome.app/contents/macos/google chrome' "$@"; }
unlike aliases, functions can exported (export -f chrome
) make them available other instances of bash; they're able perform logic (such inspecting arguments , having different behaviors based on they're passed).
wiki
Comments
Post a Comment