clip cache better as variable
This commit is contained in:
17
files/cclip
17
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
|
||||
|
||||
Reference in New Issue
Block a user