-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SublimeMerge profile_helper hook (#42)
- Loading branch information
1 parent
5777bca
commit 98078ba
Showing
3 changed files
with
108 additions
and
0 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,47 @@ | ||
#!/usr/bin/env fish | ||
|
||
# ---------------------------------------------------------------------- | ||
# Setup config variables and env | ||
# ---------------------------------------------------------------------- | ||
|
||
if test -z "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH" | ||
exit 1 | ||
end | ||
|
||
if not test -f "$BASE16_SHELL_THEME_NAME_PATH" | ||
exit 1 | ||
end | ||
|
||
# The path/to/sublime-merge/Package must be set | ||
if not test -d "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH" | ||
exit 1 | ||
end | ||
|
||
# The base16-sublime-merge repo must be cloned at | ||
if not test -d "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH/base16-sublime-merge" | ||
exit 1 | ||
end | ||
|
||
set BASE16_SHELL_SUBLIMEMERGE_SETTINGS_PATH "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH/User/Preferences.sublime-settings" | ||
|
||
# The Sublime Merge settings path should exist | ||
if not test -f "$BASE16_SHELL_SUBLIMEMERGE_SETTINGS_PATH" | ||
exit 1 | ||
end | ||
|
||
function find_replace_json_value_in_sublimemerge_settings | ||
set property $argv[1] | ||
set value $argv[2] | ||
set json_file "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH/User/Preferences.sublime-settings" | ||
|
||
# Use sed to find the property and change its value | ||
sed -i "s/\"$property\": \".*\"/\"$property\": \"$value\"/" $BASE16_SHELL_SUBLIMEMERGE_SETTINGS_PATH | ||
end | ||
|
||
# ---------------------------------------------------------------------- | ||
# Execution | ||
# ---------------------------------------------------------------------- | ||
set current_theme_name (cat "$BASE16_SHELL_THEME_NAME_PATH") | ||
|
||
find_replace_json_value_in_sublimemerge_settings "theme" "base16-$current_theme_name.sublime-theme" | ||
find_replace_json_value_in_sublimemerge_settings "color_scheme" "base16-$current_theme_name.sublime-color-scheme" |
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,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ---------------------------------------------------------------------- | ||
# Setup config variables and env | ||
# ---------------------------------------------------------------------- | ||
|
||
if [ -z "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH" ]; then | ||
exit 1 | ||
fi | ||
|
||
if ! [ -f "$BASE16_SHELL_THEME_NAME_PATH" ]; then | ||
exit 1 | ||
fi | ||
|
||
# The path/to/sublime-merge/Package must be set | ||
if ! [ -d "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH" ]; then | ||
exit 1 | ||
fi | ||
|
||
# The base16-sublime-merge repo must be cloned at | ||
if ! [ -d "$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH/base16-sublime-merge" ]; then | ||
exit 1 | ||
fi | ||
|
||
BASE16_SHELL_SUBLIMEMERGE_SETTINGS_PATH="$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH"/User/Preferences.sublime-settings | ||
|
||
# The Sublime Merge settings path should exist | ||
if ! [ -f "$BASE16_SHELL_SUBLIMEMERGE_SETTINGS_PATH" ]; then | ||
exit 1 | ||
fi | ||
|
||
find_replace_json_value_in_sublimemerge_settings() { | ||
local property=$1 | ||
local value=$2 | ||
local json_file="$BASE16_SHELL_SUBLIMEMERGE_PACKAGE_PATH"/User/Preferences.sublime-settings | ||
|
||
# Use sed to find the property and change its value | ||
sed -i "s/\"$property\": \".*\"/\"$property\": \"$value\"/" $BASE16_SHELL_SUBLIMEMERGE_SETTINGS_PATH | ||
} | ||
|
||
# ---------------------------------------------------------------------- | ||
# Execution | ||
# ---------------------------------------------------------------------- | ||
read current_theme_name < "$BASE16_SHELL_THEME_NAME_PATH" | ||
|
||
find_replace_json_value_in_sublimemerge_settings "theme" "base16-$current_theme_name.sublime-theme" | ||
find_replace_json_value_in_sublimemerge_settings "color_scheme" "base16-$current_theme_name.sublime-color-scheme" |