Hi furries, i found the forum just today and saw that there was no bash scripts thread soo i made one.
pwdp
First one is a oneliner that prints the currently focused window's pwd. I use it to open new terminals/file managers that are in the same path as the one i am in.
img_uploader
The second is slightly more error prone, if you have a webserver already running, you can modify this slightly to upload images to it fast.
What it does is, it opens a terminal(only tested in st) with ranger file managers choosefile option, writes them to a file and uploads them to your server throught scp, it uses herbe to show you information and directs the links it creates to your clipboard
dependencies are ST, herbe(optional), xclip, openssh and a webserver running in a vps, openssh configured to be used with pgpkeys.
Alongside the script above, i use this to check the links i created before
yt-dlp alias
I put this as a alias to install music videos as mp3's from youtube
pwdp
First one is a oneliner that prints the currently focused window's pwd. I use it to open new terminals/file managers that are in the same path as the one i am in.
pwdx $(ps --ppid $(xdotool getwindowfocus getwindowpid) -o pid=) | cut -d ":" -f2
img_uploader
The second is slightly more error prone, if you have a webserver already running, you can modify this slightly to upload images to it fast.
What it does is, it opens a terminal(only tested in st) with ranger file managers choosefile option, writes them to a file and uploads them to your server throught scp, it uses herbe to show you information and directs the links it creates to your clipboard
dependencies are ST, herbe(optional), xclip, openssh and a webserver running in a vps, openssh configured to be used with pgpkeys.
#!/bin/sh
SERVER="example.net"
TEMPFILE="/tmp/will_be_sent"
SERVERFILE="/path/to/webserver/root"
CACHEFILE="$HOME/.cache/uploaded_files.txt"
TERM="st"
if ! ping -c 1 $SERVER > /dev/null 2>&1 ; then
herbe "No internet Connection :("
exit;
fi
$TERM -e ranger --choosefiles=$TEMPFILE
#exit if no file is choosen
FILES=$(cat $TEMPFILE) || exit
while read -r F
do
FLINK=https://$SERVER/files/$(basename "$F")
if ! grep "$FLINK" $CACHEFILE ; then
scp -C "$F" root@$SERVER:$SERVERFILE/files && echo "$F"
echo "$FLINK" >> "$CACHEFILE"
fi
echo "$FLINK" |xclip -selection "clipboard"
herbe "$FLINK uploaded"
done < "$TEMPFILE"
rm "$TEMPFILE"
Alongside the script above, i use this to check the links i created before
tac $HOME/.cache/uploaded_files.txt | dmenu | xclip -selection "clipboard"
yt-dlp alias
I put this as a alias to install music videos as mp3's from youtube
yt-dlp -xciw -f "bestaudio/best" --audio-quality 0 --audio-format mp3 --embed-thumbnail --embed-metadata -o "%(title)s.%(ext)s"