Commit 0ca26d01 authored by Derek Willian Stavis's avatar Derek Willian Stavis

Fix theme key bindings (#334)

* init: load only key bindings from current theme

* theme: reload key bindings on theme change
parent 065bc9c6
......@@ -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
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment