dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

commit fbfa05bfad12a17b352356730a84712b401d5744
parent 2b449845a6dfe4a449eda2deb04f14956733e222
Author: Chris Noxz <chris@noxz.tech>
Date:   Tue, 22 Oct 2019 13:05:47 +0200

[tmux] Add shell aware history plugin for tmux, using fzf

Diffstat:
Abin/.bin/fzf-history.tmux | 24++++++++++++++++++++++++
Mtmux/.config/tmux/tmux.conf | 1+
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/bin/.bin/fzf-history.tmux b/bin/.bin/fzf-history.tmux @@ -0,0 +1,24 @@ +#!/bin/sh + +# make sure in tmux +[ ! -n "$TMUX" ] && return + +# make sure in shell +_TTY=$(tmux display -p "#{pane_tty}" | sed "s=/dev/==") +[ "$(pgrep -at$_TTY | grep -v "${SHELL##*/}")" ] && return + +# make sure HISTFILE is set +if [ ! -n "$HISTFILE" ] +then + HISTFILE="$HOME/.cache/ksh/history" +fi + +# get command from history file +_CMD="$(cat "$HISTFILE" \ + | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' -e '/^[[:space:]]*$/d' \ + | sort -u \ + | fzf-tmux)" + +# send keys to current session +tmux send-keys "$_CMD" +tmux send-keys "enter" diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf @@ -94,6 +94,7 @@ bind -T prefix C send-keys "C-c" \; \ send-keys "clear && tmux clear-history" \; \ send-keys "Enter" bind -T prefix / copy-mode +bind -T prefix H run "fzf-history.tmux" # mouse scrolling