short shortcuts or cclip

This commit is contained in:
Ville Rantanen
2022-11-04 16:52:16 +02:00
parent e544342fae
commit afb3f658d1

View File

@@ -21,7 +21,8 @@ Paste files using clipboard:
-s Use soft link instead of file copying
-l Use hardlink instead of file copying
-k Keep clipboard link
-m Move instead of copy (can not be used with -h, can not -k)
-m Move instead of copy (can not be used with any other switch)
Shortcut to switches example: ${HL}$SELF plk${NO} equals -l and -k
Delete source files using clipboard links (WARNING):
${HL}$SELF rm/remove clipboardname[s]${NO}
@@ -115,7 +116,6 @@ _simple_list() {
ls -1 "$STORAGE"
}
_copy() {
numargs=$#
if [[ $# -lt 2 ]]; then
@@ -166,6 +166,12 @@ _edit() {
_paste() {
numargs=$#
keeplink=0
# ps pl pk style command
if [[ "$1" =~ s ]]; then softlink=1; fi
if [[ "$1" =~ l ]]; then hardlink=1; fi
if [[ "$1" =~ k ]]; then keeplink=1; fi
if [[ "$1" =~ m ]]; then movelink=1; fi
# parse switches
for (( i=2; i<=$#; i++ )); do
case ${!i} in
-s) softlink=1; ;;
@@ -259,17 +265,16 @@ _paste_single() {
# -L dereference symlinks, -P no-deref (keep as symlink)
# -H follow symlinks
if [[ "$softlink$hardlink$movelink" =~ 11 ]]; then
_err "Can not do both soft and hard link, or mix with move link"
exit 1
fi
if [[ "$movelink" -eq 1 ]]; then
echo Moving "${1} -> $target"
mv "$1" "$target"
return $?
fi
if [[ "$softlink$hardlink" = "11" ]]; then
_err "Can not do both soft and hard link"
exit 1
fi
if [[ "$softlink" = 1 ]]; then
echo Symbolic link "${1} -> ${OUTPUT}/$target"
ln -s "${1}" "${OUTPUT}/$target"
@@ -539,7 +544,7 @@ OUTPUT=.
[[ "$CMD" = "d" || "$CMD" = "delete" || "$CMD" = "del" ]] && { _delete "$@"; }
[[ "$CMD" = "D" || "$CMD" = "Delete" || "$CMD" = "Del" ]] && { _delete_all; }
[[ "$CMD" = "e" || "$CMD" = "edit" ]] && { _edit "$@"; }
[[ "$CMD" = "p" || "$CMD" = "paste" ]] && { _paste "$@"; }
[[ "$CMD" = "p" || "$CMD" = "paste" || "$CMD" =~ ^p.$|^p..$ ]] && { _paste "$@"; }
[[ "$CMD" = "rm" || "$CMD" = "remove" ]] && { _remove "$@"; }
[[ "$CMD" = "mc" ]] && { _gui "$@"; }