paste with move
This commit is contained in:
18
files/cclip
18
files/cclip
@@ -8,9 +8,10 @@ _help() {
|
|||||||
Usage: $SELF [command] [clipboard name] [filename]
|
Usage: $SELF [command] [clipboard name] [filename]
|
||||||
|
|
||||||
Short Command Description
|
Short Command Description
|
||||||
p paste Display on screen / copies to file
|
c copy Copy from file / stdin
|
||||||
c copy Save from stdin / from file
|
|
||||||
x cut Move file to clipboard
|
x cut Move file to clipboard
|
||||||
|
p paste Paste to file / stdout
|
||||||
|
o move Paste to file, by moving (clipboard deleted)
|
||||||
d delete Delete an entry
|
d delete Delete an entry
|
||||||
D Delete Clear the whole clibboard
|
D Delete Clear the whole clibboard
|
||||||
e edit Edit contents, with \$EDITOR
|
e edit Edit contents, with \$EDITOR
|
||||||
@@ -21,6 +22,7 @@ _help() {
|
|||||||
Clipboard Name: Any string for the clipboard name. default: 0
|
Clipboard Name: Any string for the clipboard name. default: 0
|
||||||
Filename:
|
Filename:
|
||||||
If not given, defaults to clipboard name
|
If not given, defaults to clipboard name
|
||||||
|
- uses stdout/stdin
|
||||||
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:
|
When writing to clipboard:
|
||||||
@@ -184,8 +186,13 @@ _read_files() { # name, file
|
|||||||
else
|
else
|
||||||
to=" to $2"
|
to=" to $2"
|
||||||
fi
|
fi
|
||||||
|
if [[ $MOVE = true ]]; then
|
||||||
|
echo Moving "${1}$to"
|
||||||
|
mv "$STORAGE/$1" "$2"
|
||||||
|
else
|
||||||
echo Pasting "${1}$to"
|
echo Pasting "${1}$to"
|
||||||
cp -aT "$STORAGE/$1" "$2"
|
cp -aT
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_read_stdout() { # name
|
_read_stdout() { # name
|
||||||
@@ -254,11 +261,11 @@ _get_completer() {
|
|||||||
local curr_arg
|
local curr_arg
|
||||||
curr_arg=${COMP_WORDS[COMP_CWORD]}
|
curr_arg=${COMP_WORDS[COMP_CWORD]}
|
||||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||||
COMPREPLY=( $(compgen -W "help autocomplete l list c copy x cut p paste delete Delete pmenu" -- $curr_arg ) );
|
COMPREPLY=( $(compgen -W "help autocomplete l list c copy x cut p paste o move delete Delete pmenu" -- $curr_arg ) );
|
||||||
fi
|
fi
|
||||||
if [[ $COMP_CWORD -eq 2 ]]; then
|
if [[ $COMP_CWORD -eq 2 ]]; then
|
||||||
case ${COMP_WORDS[$(( $COMP_CWORD - 1 ))]} in
|
case ${COMP_WORDS[$(( $COMP_CWORD - 1 ))]} in
|
||||||
p|paste|d*)
|
o|move|p|paste|d*)
|
||||||
local IFS=$'"'"'\n'"'"'
|
local IFS=$'"'"'\n'"'"'
|
||||||
local remotelist=( $( eval CCLIP_EXEC simplelist ) )
|
local remotelist=( $( eval CCLIP_EXEC simplelist ) )
|
||||||
COMPREPLY=( $(compgen -W "${remotelist[*]}" -- $curr_arg ) );
|
COMPREPLY=( $(compgen -W "${remotelist[*]}" -- $curr_arg ) );
|
||||||
@@ -292,6 +299,7 @@ MOVE=false
|
|||||||
CMD=help
|
CMD=help
|
||||||
if [[ -z "$1" ]]; then CMD=list; fi
|
if [[ -z "$1" ]]; then CMD=list; fi
|
||||||
[[ "$1" = "p" || "$1" = "paste" ]] && { CMD=read; ARG1=$CMD; }
|
[[ "$1" = "p" || "$1" = "paste" ]] && { CMD=read; ARG1=$CMD; }
|
||||||
|
[[ "$1" = "o" || "$1" = "move" ]] && { CMD=read; ARG1=$CMD; MOVE=true; }
|
||||||
[[ "$1" = "pmenu" || "$1" = "pastemenu" ]] && { CMD=read_menu; ARG1=$CMD; }
|
[[ "$1" = "pmenu" || "$1" = "pastemenu" ]] && { CMD=read_menu; ARG1=$CMD; }
|
||||||
[[ "$1" = "c" || "$1" = "copy" ]] && { CMD=write; ARG1=$CMD; }
|
[[ "$1" = "c" || "$1" = "copy" ]] && { CMD=write; ARG1=$CMD; }
|
||||||
[[ "$1" = "x" || "$1" = "cut" ]] && { CMD=write; ARG1=$CMD; MOVE=true; }
|
[[ "$1" = "x" || "$1" = "cut" ]] && { CMD=write; ARG1=$CMD; MOVE=true; }
|
||||||
|
|||||||
Reference in New Issue
Block a user