clip cache better as variable
This commit is contained in:
17
files/cclip
17
files/cclip
@@ -17,28 +17,23 @@ _help() {
|
|||||||
Filename:
|
Filename:
|
||||||
When reading from clipboard:
|
When reading from clipboard:
|
||||||
File or folder to write the clipboard contents. If omitted: stdout
|
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
|
File or folder to read from. If omitted: stdin
|
||||||
|
|
||||||
Shorthand:
|
Shorthand:
|
||||||
echo my data | $SELF 1 # writes data with name: 1
|
echo my data | $SELF 1 # writes data with name: 1
|
||||||
$SELF 1 | cat - # prints the contents of file: 1
|
$SELF 1 | cat - # prints the contents of file: 1
|
||||||
|
|
||||||
|
Config:
|
||||||
|
CCLIP_HOME environment variable sets clipboard storage path,
|
||||||
|
defauls to ~/.cache/cclip
|
||||||
"
|
"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_load_config(){
|
_load_config(){
|
||||||
STORAGE=~/.cache/cclip
|
STORAGE=${CCLIP_HOME:-~/.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
|
|
||||||
mkdir -p "$STORAGE"
|
mkdir -p "$STORAGE"
|
||||||
[[ -e "$STORAGE"/0 ]] || {
|
[[ -e "$STORAGE"/0 ]] || {
|
||||||
echo Sample data | _write_stdin 0
|
echo Sample data | _write_stdin 0
|
||||||
|
|||||||
Reference in New Issue
Block a user