clip cache better as variable

This commit is contained in:
q
2018-08-13 22:16:47 +03:00
parent a3f7f858ff
commit 07c2ae2acb

View File

@@ -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