]> Sergey Matveev's repositories - dotfiles.git/commitdiff
Refactored tmux fzf menus
authorSergey Matveev <stargrave@stargrave.org>
Mon, 21 Feb 2022 10:07:05 +0000 (13:07 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 21 Feb 2022 15:22:08 +0000 (18:22 +0300)
14 files changed:
tmux/.tmux.conf
tmux/.tmux/bin/common.sh [moved from tmux/bin/tmux-common.sh with 100% similarity]
tmux/.tmux/bin/fzf.zsh [new file with mode: 0755]
tmux/.tmux/bin/menu-calc.sh [moved from tmux/bin/tmux-menu-calc.sh with 100% similarity]
tmux/.tmux/bin/menu-dict.sh [moved from tmux/bin/tmux-menu-dict.sh with 100% similarity]
tmux/.tmux/bin/menu-music.sh [moved from tmux/bin/tmux-menu-music.sh with 100% similarity]
tmux/.tmux/bin/menu-pass-session.sh [moved from tmux/bin/tmux-menu-pass-session.sh with 100% similarity]
tmux/.tmux/bin/menu-pass.sh [moved from tmux/bin/tmux-menu-pass.sh with 100% similarity]
tmux/.tmux/functions.zsh/tmux-fzf-find [new file with mode: 0644]
tmux/.tmux/functions.zsh/tmux-fzf-git-branches [new file with mode: 0644]
tmux/.tmux/functions.zsh/tmux-fzf-git-commits [new file with mode: 0644]
tmux/.tmux/functions.zsh/tmux-fzf-git-files [new file with mode: 0644]
tmux/bin/tmux-fzf.zsh [deleted file]
x/bin/start-im

index 3623ea3d685be6d88ecd73d692ccad89b9b9e8f8..1907cc7d2d47c811b38577adbdcb25e25a6e520e 100644 (file)
@@ -56,15 +56,15 @@ bind-key Y {
 }
 
 bind-key t display-menu \
-    music t "display-popup -E -w 100% '~/bin/tmux-menu-music.sh'" \
-    pass p "display-popup -E '~/bin/tmux-menu-pass-session.sh'" \
-    dict d "display-popup -E -h 100% '~/bin/tmux-menu-dict.sh'" \
-    calc c "display-popup -E '~/bin/tmux-menu-calc.sh'" \
+    music t "display-popup -E -w 100% '~/.tmux/bin/menu-music.sh'" \
+    pass p "display-popup -E '~/.tmux/bin/menu-pass-session.sh'" \
+    dict d "display-popup -E -h 100% '~/.tmux/bin/menu-dict.sh'" \
+    calc c "display-popup -E '~/.tmux/bin/menu-calc.sh'" \
     cal l "display-popup 'cal -3N'" \
     top o "display-popup -E -h 100% 'top -s 1'"
 
 bind-key o display-menu \
-    find o "display-popup -E -w 100% \"~/bin/tmux-fzf.zsh find '#{pane_current_path}'\"" \
-    git-files g "display-popup -E -w 100% \"~/bin/tmux-fzf.zsh git-files '#{pane_current_path}'\"" \
-    git-branches b "display-popup -E -w 100% \"~/bin/tmux-fzf.zsh git-branches '#{pane_current_path}'\"" \
-    git-commits c "display-popup -E -w 100% \"~/bin/tmux-fzf.zsh git-commits '#{pane_current_path}'\""
+    find o "display-popup -E -w 100% \"~/.tmux/bin/fzf.zsh find '#{pane_current_path}'\"" \
+    git-files g "display-popup -E -w 100% \"~/.tmux/bin/fzf.zsh git-files '#{pane_current_path}'\"" \
+    git-branches b "display-popup -E -w 100% \"~/.tmux/bin/fzf.zsh git-branches '#{pane_current_path}'\"" \
+    git-commits c "display-popup -E -w 100% \"~/.tmux/bin/fzf.zsh git-commits '#{pane_current_path}'\""
diff --git a/tmux/.tmux/bin/fzf.zsh b/tmux/.tmux/bin/fzf.zsh
new file mode 100755 (executable)
index 0000000..8872926
--- /dev/null
@@ -0,0 +1,13 @@
+#!/usr/bin/env zsh
+
+cd $2
+set -e
+fpath=(~/.tmux/functions.zsh $fpath)
+autoload tmux-fzf-$1
+tmp=`mktemp`
+trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
+tmux-fzf-$1 > $tmp || { echo unknown command ; sleep 1 ; exit }
+[[ -s $tmp ]] || exit
+tmux set-buffer "`perl -npe 's/\n/ /g' $tmp`"
+tmux paste-buffer
+tmux delete-buffer
diff --git a/tmux/.tmux/functions.zsh/tmux-fzf-find b/tmux/.tmux/functions.zsh/tmux-fzf-find
new file mode 100644 (file)
index 0000000..c114afd
--- /dev/null
@@ -0,0 +1,6 @@
+bfs -L . -mindepth 1 \
+    -path "*/.git" -prune -o \
+    -path "*/.redo" -prune -o \
+    \( -type f -o -type d -o -type l \) -print |
+cut -c3- | fzf -m --preview="less -N -S {}" |
+while read fn ; do print ${(q)fn} ; done
diff --git a/tmux/.tmux/functions.zsh/tmux-fzf-git-branches b/tmux/.tmux/functions.zsh/tmux-fzf-git-branches
new file mode 100644 (file)
index 0000000..91aa633
--- /dev/null
@@ -0,0 +1,2 @@
+{ git branch ; git branch --remote } | sed "s/ //g" |
+fzf --preview "git log --oneline --graph --decorate=short --color=always {}"
diff --git a/tmux/.tmux/functions.zsh/tmux-fzf-git-commits b/tmux/.tmux/functions.zsh/tmux-fzf-git-commits
new file mode 100644 (file)
index 0000000..47198cf
--- /dev/null
@@ -0,0 +1,2 @@
+git --no-pager log --oneline -n 100 | perl -ne 'print "@~$n $_"; $n++' |
+fzf --reverse | cut -w -f1
diff --git a/tmux/.tmux/functions.zsh/tmux-fzf-git-files b/tmux/.tmux/functions.zsh/tmux-fzf-git-files
new file mode 100644 (file)
index 0000000..35180f8
--- /dev/null
@@ -0,0 +1,3 @@
+git status --short |
+fzf -m --delimiter " " --preview "git diff --color=always {-1}" |
+perl -npe 's/^\s*\S+\s+//'
diff --git a/tmux/bin/tmux-fzf.zsh b/tmux/bin/tmux-fzf.zsh
deleted file mode 100755 (executable)
index 2eff748..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env zsh
-
-cd $2
-set -e
-tmp=`mktemp`
-trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
-
-case $1 in
-(find)
-    bfs -L . -mindepth 1 \
-        -path "*/.git" -prune -o \
-        -path "*/.redo" -prune -o \
-        \( -type f -o -type d -o -type l \) -print |
-    cut -c3- | fzf -m --preview="less -N -S {}" |
-    while read fn ; do print ${(q)fn} ; done > $tmp
-    ;;
-(git-files) git status --short | fzf -m | perl -npe 's/^\s*\S+\s+//' > $tmp ;;
-(git-branches) { git branch ; git branch --remote } | fzf > $tmp ;;
-(git-commits)
-    git --no-pager log --oneline -n 20 | perl -ne "print \"@~\$n \$_\"; \$n++" |
-    fzf --reverse | cut -w -f1 > $tmp
-    ;;
-(*) echo unknown command ; sleep 1 ; exit ;;
-esac
-
-[ -s $tmp ] || exit
-tmux set-buffer "`perl -npe 's/\n/ /g' $tmp`"
-tmux paste-buffer
-tmux delete-buffer
index 2e3373fed6282c7e707291139bcf381fe6b33e35..9fe966faaf7ce043c7ec635d0d6ea96c00b59064 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/zsh
 
-. ~/bin/tmux-common.sh
+. ~/.tmux/bin/common.sh
 
 tmux has-session -t im && exit
 tmux new-session -d -s im