diff --git a/README.md b/README.md index 355acfc..f0d2cf4 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Don't hesitate to open an issue if not. ### Damn I Lost the Clipboard Content Don't worry, you won't have to type it all again. -vimclip stores your input in a temporary file at `/tmp/vimclip.XXXXXXXX` (where XXX... is replaced by a random string). +vimclip stores your input in a temporary file at `/tmp/vimclip/vimclip.XXXXXXXX` (where XXX... is replaced by a random string). So if you accidentally copied something else into your clipboard before pasting your vimclip input, just go and grab the content from there. ### I Want to Use Another Editor diff --git a/vimclip b/vimclip index 8c4f5db..9e0b96a 100755 --- a/vimclip +++ b/vimclip @@ -5,22 +5,27 @@ if ! [ -x "$(command -v $EDITOR)" ]; then exit 1 fi +if [ -z "$TMPDIR" ]; then + TMPDIR=/tmp +fi +mkdir -p "$TMPDIR/vimclip" + if [ "Darwin" = $(uname -s) ]; then if ! [ -x "$(command -v pbcopy)" ]; then echo 'Error: pbcopy is not available.' >&2 exit 1 fi - TMP=$(mktemp -t vimclip) - $EDITOR $TMP - pbcopy < $TMP + TMP=$(mktemp -t vimclip/vimclip) + $EDITOR "$TMP" + pbcopy < "$TMP" else if ! [ -x "$(command -v xsel)" ]; then echo 'Error: xsel is not available.' >&2 exit 1 fi - TMP=$(mktemp -p /tmp -t vimclip.XXXXXXXX) - $EDITOR $TMP - xsel -i -b < $TMP + TMP=$(mktemp -p "$TMPDIR/vimclip" -t vimclip.XXXXXXXX) + $EDITOR "$TMP" + xsel -i -b < "$TMP" fi