This commit is contained in:
Dimitris Marakomihelakis 2023-08-20 20:40:25 +03:00
parent e4f2d6ceec
commit 120a7b5555

48
util/clipnote.sh Normal file
View file

@ -0,0 +1,48 @@
:<<'info'
shellnotes - .clearlogs.sh
(C) Dimitris Marakomihelakis
Released under the "All rights reserved" category. See the RIGHTS.txt file
in /docs/github/ for its full text.
info
function clipnote() {
function _write_clipboard() {
if ! command -v xclip &> /dev/null; then
echo "Error: xclip is not installed. Please install it."
exit 1
fi
clipboard_content=$(xclip -selection clipboard -o)
echo "$clipboard_content" > $DEFAULT_PATH/$1
}
if [ $# -eq 0 ]; then
echo "No note name given."
echo -n "Enter note name: " && read input
if [ -z "$input" ]; then
echo "No input given."
else
_write_clipboard $input
fi
else
case $1 in
-r | --reverse )
if [ $# -eq 2 ]; then
file_content=$(quickread "$2")
echo -n "$file_content" | xclip -selection clipboard
else
echo "No note name given."
echo "Usage: clipnote -r <notename>"
fi
;;
*)
_write_clipboard $1
;;
esac
fi
}