Fix theme key bindings (#334)

* init: load only key bindings from current theme

* theme: reload key bindings on theme change
This commit is contained in:
Derek Willian Stavis 2016-06-03 18:13:16 -03:00
parent 065bc9c649
commit 0ca26d01e2
2 changed files with 11 additions and 5 deletions

View File

@ -25,13 +25,15 @@ emit perf:timer:finish "Oh My Fish init installed packages"
functions -q fish_user_key_bindings
and functions -c fish_user_key_bindings __original_fish_user_key_bindings
# Override key bindings, calling original if existent
function fish_user_key_bindings
# Read packages key bindings
for file in {$OMF_CONFIG,$OMF_PATH}/{,pkg,theme}/*/key_bindings.fish
function fish_user_key_bindings -V theme
# Prepare packages key bindings paths
set -l key_bindings $OMF_CONFIG/key_binding?.fish \
{$OMF_CONFIG,$OMF_PATH}/pkg/*/key_bindings.fish \
{$OMF_CONFIG,$OMF_PATH}/themes/$theme/key_binding?.fish
# Source all keybindings collected
for file in $key_bindings
source $file
end
# Read custom key bindings file
source $OMF_CONFIG/key_bindings.fish ^/dev/null
# Call original key bindings if existent
functions -q __original_fish_user_key_bindings
and __original_fish_user_key_bindings

View File

@ -30,6 +30,10 @@ function omf.theme.set -a target_theme
end
end
# If key bindings file found, reload fish key bindings
test (count {$OMF_CONFIG,$OMF_PATH}/key_binding?.fish) -gt 0
and __fish_reload_key_bindings
# Persist the changes
echo "$target_theme" > "$OMF_CONFIG/theme"