From cd64a777c3ee3e68d0ba7641bc6c79fcacf62c95 Mon Sep 17 00:00:00 2001 From: Julian Aron Prenner Date: Sun, 19 Jan 2014 10:27:39 +0100 Subject: [PATCH] Set $fish_bind_mode to default on fish startup; set $fish_key_bindings when sourcing fish_vi_mode.fish --- env.cpp | 3 +++ input.cpp | 3 --- input.h | 1 + share/functions/fish_vi_key_bindings.fish | 9 +++++++++ share/functions/fish_vi_mode.fish | 4 ++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/env.cpp b/env.cpp index ab7f63e5d..f349f5b1a 100644 --- a/env.cpp +++ b/env.cpp @@ -652,6 +652,9 @@ void env_init(const struct config_paths_t *paths /* or NULL */) /* Set g_use_posix_spawn. Default to true. */ env_var_t use_posix_spawn = env_get_string(L"fish_use_posix_spawn"); g_use_posix_spawn = (use_posix_spawn.missing_or_empty() ? true : from_string(use_posix_spawn)); + + /* Set fish_bind_mode to "default" */ + env_set(FISH_BIND_MODE_VAR, DEFAULT_BIND_MODE, ENV_GLOBAL); } void env_destroy() diff --git a/input.cpp b/input.cpp index a10bcc695..c59424329 100644 --- a/input.cpp +++ b/input.cpp @@ -61,9 +61,6 @@ #include #define DEFAULT_TERM L"ansi" - -#define FISH_BIND_MODE_VAR L"fish_bind_mode" - /** Struct representing a keybinding. Returned by input_get_mappings. */ diff --git a/input.h b/input.h index 7eb9343a2..d74122128 100644 --- a/input.h +++ b/input.h @@ -13,6 +13,7 @@ inputrc information for key bindings. #define DEFAULT_BIND_MODE L"default" +#define FISH_BIND_MODE_VAR L"fish_bind_mode" /** Key codes for inputrc-style keyboard functions that are passed on diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 03889da78..c89f6f16b 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -193,6 +193,15 @@ function fish_vi_key_bindings -d "vi-like key bindings for fish" bind -M visual h backward-char bind -M visual l forward-char + bind -M visual b backward-word + bind B backward-word + bind gE backward-word + bind gE backward-word + bind w forward-word + bind W forward-word + bind e forward-word + bind E forward-word + bind -M visual -m default d kill-selection end-selection force-repaint bind -M visual -m default y kill-selection yank end-selection force-repaint bind -M visual -m default '"*y' "commandline -s | xsel -p" end-selection force-repaint diff --git a/share/functions/fish_vi_mode.fish b/share/functions/fish_vi_mode.fish index e759b7ae0..46a2a27d6 100644 --- a/share/functions/fish_vi_mode.fish +++ b/share/functions/fish_vi_mode.fish @@ -1,5 +1,5 @@ function fish_prompt fish_vi_prompt end - -fish_vi_key_bindings +set fish_key_bindings fish_vi_key_bindings +#fish_vi_key_bindings