From be75b0b43e7fea58f6750789f3a4ec2b460ed0a2 Mon Sep 17 00:00:00 2001 From: mistahchris Date: Sat, 17 Feb 2018 14:19:56 -0600 Subject: [PATCH] add support for $VISUAL editor remove osx only feature for pasting contents of buffer --- .gitignore | 1 + bin/run | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f54d20a..6178e90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # generated by vim-anywhere on OSX only .path +/.DS_Store diff --git a/bin/run b/bin/run index 2515702..900c6c4 100755 --- a/bin/run +++ b/bin/run @@ -34,7 +34,6 @@ done ### # run ### - AW_PATH=$HOME/.vim-anywhere TMPFILE_DIR=/tmp/vim-anywhere TMPFILE=$TMPFILE_DIR/doc-$(date +"%y%m%d%H%M%S") @@ -56,7 +55,17 @@ touch $TMPFILE # Linux if [[ $OSTYPE == "linux-gnu" ]]; then chmod o-r $TMPFILE # Make file only readable by you - gvim $VIM_OPTS $TMPFILE + text_editor="$(which gvim) $VIM_OPTS" + + # if $VISUAL is specified, use that instead of gvim + if [ -e $HOME/.profile ]; then + source $HOME/.profile + if env | grep -q "VISUAL"; then + text_editor="$VISUAL" + fi; + fi; + + $text_editor $TMPFILE cat $TMPFILE | xclip -selection clipboard # OSX @@ -67,14 +76,23 @@ elif [[ $OSTYPE == "darwin"* ]]; then app=$(osascript $AW_PATH/script/current_app.scpt) mvim_path=$(cat $AW_PATH/.path) + text_editor="$mvim_path $VIM_OPTS" require_file_exists $mvim_path \ "mvim must have been move or uninstalled.\nPlease make sure it is" \ "available in your path and then reinstall vim-anywhere." - $mvim_path $VIM_OPTS $TMPFILE + # if $VISUAL is specified, use that instead of mvim + if [ -e $HOME/.profile ]; then + source $HOME/.profile + if env | grep -q "VISUAL"; then + text_editor="$VISUAL" + fi; + fi; + + $text_editor $TMPFILE # todo, fix invalid file - + # NOTE # Here we set LANG explicitly to be UTF-8 compatible when copying text. The only way that was explicitly # setting this to en_US.UTF-8. This may eventually cause issues with other languages. If so, just remove