dotfiles

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

fzf-history.tmux (650B)


      1 #!/bin/sh
      2 
      3 # make sure in tmux
      4 [ ! -n "$TMUX" ] && return
      5 
      6 # make sure in shell
      7 _TTY=$(tmux display -p "#{pane_tty}" | sed "s=/dev/==")
      8 [ "$(pgrep -at$_TTY | grep -v "${SHELL##*/}")" ] && return
      9 
     10 # make sure HISTFILE is set
     11 if [ ! -n "$HISTFILE" ]
     12 then
     13 	HISTFILE="$HOME_CACHE_HOME/ksh/history"
     14 fi
     15 
     16 # get command from history file
     17 _CMD="$(cat "$HISTFILE"                                                     \
     18 	| sed -e 's/^[ \t]*//' -e 's/[ \t]*$//' -e '/^[[:space:]]*$/d'          \
     19 	| sort -u                                                               \
     20 	| fzf-tmux)"
     21 
     22 # send keys to current session
     23 tmux send-keys "$_CMD"
     24 tmux send-keys "enter"