From 22359f9981223280cdd958e90d0531614b2a90ef Mon Sep 17 00:00:00 2001 From: Jesus Perez Date: Sat, 9 Feb 2019 23:53:26 -0400 Subject: [PATCH] Add c switch to edit the clipboard contents. From: * https://github.com/cknadler/vim-anywhere/pull/99 * https://github.com/cknadler/vim-anywhere/pull/69 * https://github.com/cknadler/vim-anywhere/pull/52 --- vim_anywhere | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vim_anywhere b/vim_anywhere index 057c2fe..63a1b01 100755 --- a/vim_anywhere +++ b/vim_anywhere @@ -9,9 +9,10 @@ # # Modified by Jesús Pérez to use terminal neovim and work only on linux -while getopts ":v" opt; do +while getopts ":cv" opt; do case "$opt" in v) set -x ;; + c) read_clipboard='true' ;; \?) echo "Invalid option: -$OPTARG" >&2 ;; esac done @@ -23,7 +24,12 @@ TMPFILE=$TMPFILE_DIR/doc-$(date +"%y%m%d%H%M%S") mkdir -p $TMPFILE_DIR touch $TMPFILE -# Linux chmod o-r $TMPFILE # Make file only readable by you + +if [[ $read_clipboard == 'true' ]]; then + xclip -o -selection clipboard > $TMPFILE +fi + $TERMINAL -e nvim $TMPFILE + cat $TMPFILE | xclip -selection clipboard