From d0f3684cd5da6ce07a2b5fdc548fe8d7c54f97e9 Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Wed, 8 Jun 2022 14:50:17 +0200 Subject: [PATCH] snippet fix --- dot_bashrc.d/fzf-snippet.bashrc | 8 ++++++++ dot_tmux.conf | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 dot_bashrc.d/fzf-snippet.bashrc diff --git a/dot_bashrc.d/fzf-snippet.bashrc b/dot_bashrc.d/fzf-snippet.bashrc new file mode 100644 index 0000000..59ac1ca --- /dev/null +++ b/dot_bashrc.d/fzf-snippet.bashrc @@ -0,0 +1,8 @@ +# edit single line snippet +cfg-snippetrc() { $EDITOR ~/.snippetrc ;} + +fzf-snippet() { + selected="$(cat ~/.snippetrc | sed '/^$/d' | sort -n | fzf -e -i )" + # remove tags, leading and trailing spaces, also no newline + echo "$selected" | sed -e s/\;\;\.\*\$// | sed 's/^[ \t]*//;s/[ \t]*$//' | tr -d '\n' | xclip -selection clipboard +} diff --git a/dot_tmux.conf b/dot_tmux.conf index 3cc7f78..62adc3e 100644 --- a/dot_tmux.conf +++ b/dot_tmux.conf @@ -116,6 +116,9 @@ bind-key Home send-keys "$FAVORITE_COMMAND" unbind r bind r source-file ~/.tmux.conf \; display-message "config reloaded!" +# inspired from fzf-snippet (https://github.com/gotbletu/shownotes/blob/master/fzf-snippet.md) +bind-key "'" new-window -n snippet \; send-keys "fzf-snippet && tmux kill-window\n" + # plugin last_command_output set -g @command-capture-prompt-pattern '$ ' set -g @command-capture-editor-cmd 'gedit -'