diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2022-03-12 19:54:51 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2022-03-12 19:54:51 +0530 |
commit | 54b772cae06eb25adf33297e35234f33ded81a7b (patch) | |
tree | f287ee48faa8013e4a8f0ee764a6d3cd850bb24d /.scripts/upmenu | |
parent | 7197e45d94dbcf4877d585fff8e634896876ae83 (diff) |
neovim addition
Diffstat (limited to '.scripts/upmenu')
-rwxr-xr-x | .scripts/upmenu | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/.scripts/upmenu b/.scripts/upmenu new file mode 100755 index 0000000..f600e3a --- /dev/null +++ b/.scripts/upmenu @@ -0,0 +1,46 @@ +#!/bin/sh + +# hello guys its mokuken!! + +function upmenu { + options="Upload a File\nRecent Uploads\nCancel" + selected=$(echo -e $options | dmenu -l 3 ) + if [[ "$selected" == "Upload a File" ]]; then + + target="$1" + [ -z "$target" ] && target="$(realpath .)" + + while :; do + sel="$(ls -1a "$target" | grep -v '^\.$' | dmenu -l 25 )" || exit + if [ "$(echo "$sel" | cut -b1)" = "/" ]; then + newt="$sel" + else + newt="$(realpath "$target/$sel")" + fi + if [ -e "$newt" ]; then + target="$newt" + if [ ! -d "$target" ]; then + echo "Location: $target" + command="curl -s -F'file=@$target' https://0x0.st" + echo "Executing: $command" + + url=$(eval $command) + echo "URL: $url" + + printf "$url" | xclip -sel clip + notify-send "File Uploaded" "URL: $url \ncopied to clipboard" -t 5000 -i "$HOME/.program/icon.png" + + entry="$(date '+%d-%m-%y-%H:%M:%S') $url $(echo $target | awk -F'/' '{print $(NF)}')" + echo $entry >> $HOME/.0x0_list + echo "Uploaded"; break + fi + fi + done + elif [[ "$selected" == "Recent Uploads" ]]; then + cat ~/.0x0_list | dmenu -l 10 + elif [[ "$selected" == "Cancel" ]]; then + return + fi +} + +upmenu |