-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed: passing command line arguments (like urls) now works
- Loading branch information
1 parent
daac18a
commit be41db3
Showing
9 changed files
with
63 additions
and
61 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function __gchrome_base_dir | ||
if not set -q __gchrome_base_dir | ||
if test -d "$HOME/.config/google-chrome" | ||
set __gchrome_base_dir "$HOME/.config/google-chrome" | ||
else | ||
set __gchrome_base_dir "$HOME/Library/Application Support/Google/Chrome" | ||
end | ||
end | ||
echo $__gchrome_base_dir | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function __gchrome_check_dependencies | ||
if not which -s jq | ||
echo "gchrome: google-chrome profile launcher | ||
Missing dependency: `jq` not found. (`jq` is a lightweight and flexible command-line JSON processor.) | ||
Install it with something like: | ||
`brew install jq` | ||
or | ||
`sudo apt-get install jq`" | ||
return 1 | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function __gchrome_executable | ||
if not set -q __gchrome_executable | ||
if test -f "/usr/bin/google-chrome" | ||
set __gchrome_executable "/usr/bin/google-chrome" | ||
else if test -f "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" | ||
set __gchrome_executable "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" | ||
else | ||
echo "Can't find Chrome executable" >&2 | ||
return 1 | ||
end | ||
end | ||
echo $__gchrome_executable | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function __gchrome_get_last_used_profile | ||
set -l __gchrome_base_dir (__gchrome_base_dir) | ||
jq -r '.profile.last_used' "$__gchrome_base_dir/Local State" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function __gchrome_get_profiles | ||
set -l __gchrome_base_dir (__gchrome_base_dir) | ||
jq -r '[.profile.info_cache | to_entries[] | {"key": .key, "value": .value.name}] | .[] | "\(.value|@sh)\t\(.key|@sh)"' "$__gchrome_base_dir/Local State" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function __gchrome_is_valid_profile | ||
set -l __gchrome_base_dir (__gchrome_base_dir) | ||
set -l profile_path "$__gchrome_base_dir/$argv[1]" | ||
[ -n "$argv[1]" ] && | ||
[ -d (readlink -f "$profile_path") ] && | ||
[ -f (readlink -f "$profile_path/Cookies") ] | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function __gchrome_is_valid_profile_alias | ||
if [ -z $argv[1] ]; return 1; end | ||
|
||
set -l profile (__gchrome_get_profile_from_alias $argv[1]) | ||
__gchrome_is_valid_profile $profile && return 0 || return 1 | ||
end |
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