summaryrefslogtreecommitdiff
path: root/modules/programs
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-11-07 22:47:17 +0100
committerDaiderd Jordan <daiderd@gmail.com>2016-11-07 22:47:17 +0100
commit8b8cab4e8131d6bfe4bdf00362d9cee4bd6560d9 (patch)
tree35f201f29ad3e93fbc7b2189250fb53549f682d0 /modules/programs
parent81b8a44e400569717385556c17b34eb9d14410c5 (diff)
add programs.tmux.enableFzf option
Diffstat (limited to 'modules/programs')
-rw-r--r--modules/programs/tmux.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix
index ea17d3d..5f8264d 100644
--- a/modules/programs/tmux.nix
+++ b/modules/programs/tmux.nix
@@ -15,6 +15,14 @@ let
tmuxOptions = concatMapStringsSep "\n" (attr: attr.text) (attrValues cfg.tmuxOptions);
+ fzfTmuxSession = pkgs.writeScript "fzf-tmux-session" ''
+ #! ${stdenv.shell}
+ set -e
+
+ session=$(tmux list-sessions -F '#{session_name}' | fzf --query="$1" --exit-0)
+ tmux switch-client -t "$session"
+ '';
+
in {
options = {
@@ -44,6 +52,15 @@ in {
'';
};
+ programs.tmux.enableFzf = mkOption {
+ type = types.bool;
+ default = false;
+ example = true;
+ description = ''
+ Enable fzf keybindings for selecting sessions and panes.
+ '';
+ };
+
programs.tmux.enableVim = mkOption {
type = types.bool;
default = false;
@@ -102,6 +119,11 @@ in {
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
'';
+ programs.tmux.tmuxOptions.fzf.text = mkIf cfg.enableFzf ''
+ bind-key -n M-p run "tmux split-window -p 40 -c '#{pane_current_path}' 'tmux send-keys -t #{pane_id} \"$(fzf -m | paste -sd\\ -)\"'"
+ bind-key -n M-s run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(${fzfTmuxSession})\"'"
+ '';
+
programs.tmux.tmuxOptions.vim.text = mkIf cfg.enableVim (''
setw -g mode-keys vi