aboutsummaryrefslogtreecommitdiff
path: root/clip-capture
diff options
context:
space:
mode:
Diffstat (limited to 'clip-capture')
-rwxr-xr-xclip-capture16
1 files changed, 8 insertions, 8 deletions
diff --git a/clip-capture b/clip-capture
index 8bedcda..5184430 100755
--- a/clip-capture
+++ b/clip-capture
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
-OUTFILE="${OUTFILE:-$HOME/.clips}"
+OUTFILE="${OUTFILE:-$HOME/docs/vimwiki/inbox/clips.md}"
HAS_NOTIFY=$(command -v notify-send >/dev/null 2>&1 && echo 1 || echo 0)
notify() {
@@ -17,13 +17,13 @@ die() {
get_clipboard() {
local out
if command -v xclip >/dev/null 2>&1; then
- out="$(xclip -o -selection clipboard 2>/dev/null)"
- [[ -z "$out" ]] && out="$(xclip -o -selection primary 2>/dev/null)"
+ out="$(xclip -o -selection primary 2>/dev/null)"
+ [[ -z "$out" ]] && out="$(xclip -o -selection clipboard 2>/dev/null)"
printf '%s' "$out"; return
fi
if command -v xsel >/dev/null 2>&1; then
- out="$(xsel --clipboard --output 2>/dev/null)"
- [[ -z "$out" ]] && out="$(xsel --primary --output 2>/dev/null)"
+ out="$(xsel --primary --output 2>/dev/null)"
+ [[ -z "$out" ]] && out="$(xsel --clipboard --output 2>/dev/null)"
printf '%s' "$out"; return
fi
die "need xclip or xsel"
@@ -34,12 +34,12 @@ clip="$(get_clipboard)"
ts="$(date '+%Y-%m-%d %H:%M:%S')"
{
- printf '# captured %s\n' "$ts"
+ printf '## captured %s\n' "$ts"
printf '%s\n' "$clip"
- printf -- '---\n'
+ printf -- '\n'
} >> "$OUTFILE"
lines="$(printf '%s\n' "$clip" | wc -l | awk '{print $1}')"
chars="${#clip}"
-notify normal "capture-clip" "Saved to ~/.clips ($lines lines, $chars chars)"
+notify normal "capture-clip" "Saved to vimwiki/inbox/clips.md ($lines lines, $chars chars)"