From 07c2ae2acb50237bc9c7681543467cb94c514723 Mon Sep 17 00:00:00 2001 From: q Date: Mon, 13 Aug 2018 22:16:47 +0300 Subject: [PATCH] clip cache better as variable --- files/cclip | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/files/cclip b/files/cclip index a7d45f4..43bfbcb 100755 --- a/files/cclip +++ b/files/cclip @@ -17,28 +17,23 @@ _help() { Filename: When reading from clipboard: File or folder to write the clipboard contents. If omitted: stdout - When writing to clipboard:g/ + When writing to clipboard: File or folder to read from. If omitted: stdin Shorthand: echo my data | $SELF 1 # writes data with name: 1 $SELF 1 | cat - # prints the contents of file: 1 + + Config: + CCLIP_HOME environment variable sets clipboard storage path, + defauls to ~/.cache/cclip " exit } _load_config(){ - STORAGE=~/.cache/cclip - CONFIG=~/.config/cclip/config - - [[ -f "$CONFIG" ]] || { - mkdir -p $( dirname "$CONFIG" ) - echo STORAGE=$STORAGE > "$CONFIG" - _msg "created config in "$CONFIG"" - } - [[ -f "$CONFIG" ]] && . "$CONFIG" - # TODO, run line by line for security, get only lines with matching config item + STORAGE=${CCLIP_HOME:-~/.cache/cclip} mkdir -p "$STORAGE" [[ -e "$STORAGE"/0 ]] || { echo Sample data | _write_stdin 0