add programs.tmux.enableFzf option

This commit is contained in:
Daiderd Jordan 2016-11-07 22:47:17 +01:00
parent 81b8a44e40
commit 8b8cab4e81
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 26 additions and 3 deletions

View file

@ -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