OC by @als@lemmy.blahaj.zone
A while ago I made a tiny function in my ~/.zshrc to download a video from the link in my clipboard. I use this nearly every day to share videos with people without forcing them to watch it on whatever site I found it. What’s a script/alias that you use a lot?
# Download clipboard to tmp with yt-dlp tmpv() { cd /tmp/ && yt-dlp "$(wl-paste)" }
Wouldn’t say I use it often, but this thing resolves a domain name to an IP address:
function resolve() { case $1 in -4) getent ahostsv4 $2 | grep STREAM | head -n 1 | cut -d ' ' -f 1 ;; -6) getent ahostsv6 $2 | grep STREAM | head -n 1 | cut -d ' ' -f 1 ;; -p) getent hosts $2 | head -n 1 | cut -d ' ' -f 1 ;; *) getent ahosts $1 | grep STREAM | cut -d ' ' -f 1 | sort -u ;; esac }
All my aliases are just default arguments for programs or shorthands for my other scripts, most of which are specific for my setup.
This is a very good argument for
ffmpeg
andffprobe
, by the way:alias ffmpeg="ffmpeg -hide_banner" alias ffprobe="ffprobe -hide_banner"
It’s not terribly exciting but I find myself using this a lot:
#!/bin/sh echo "$*" | sed -e "s/x/*/g" | bc -l
Just a little shorthand for bc that allows me to write “x” instead of “*” to avoid shell expansion nonsense. I put it in ~/.local/bin/= so I can e.g. just write
= 17+4x5
. Combined with a Quake-style terminal this is much faster than launching a calculator app. It’s a script instead of an alias so it works regardless of the shell I’m currently using.The call to
bc -l
could be replaced with one toqalc -t
if you know qalc to be present on the system .in my .gitconfig i have
[alias] glg = log --oneline --decorate --all --graph
This allows me to get a quick overview over all branches with pushes that are recent enough for most cases.
I was unfamiliar with the decorate flag, but I can’t see any difference after trying.
I will say this is one command I absolutely refuse to create an alias for.
I have force committed to memory the command:
git log --graph --remotes --all
(and the variation with the--oneline
flag appended to the end if needed) so I can use it anywhere.It’s the one command I can’t live without.
alias ban_me_discord_i_dare_you 'sh -c "$(curl -sS https://raw.githubusercontent.com/Vendicated/VencordInstaller/main/install.sh)"'
for when discord pushes a new update
fmux
. Create a tmux session using the fish shellI am using Music Player Daemon, and I use the following script to turn gPodder into a client. My music is in
~/Music
and I put the podcasts in~/Music/Podcasts
. The script works for both streaming or downloaded podcasts.[~]$ cat bin/mpcut.sh #!/bin/bash if [ "$(echo "$1" | cut -b-4)" = "http" ]; then /usr/bin/mpc pause /usr/bin/mpc insert "$1" /usr/bin/mpc toggle /usr/bin/notify-send -i gpodder "$1 inserted to next spot in playlist." else /usr/bin/mpc pause /usr/bin/mpc add "Podcasts/$(echo "$1" | cut -d"/" -f6-)" /usr/bin/mpc toggle /usr/bin/notify-send -i gpodder "$(echo "$1" | cut -d"/" -f7-)" "added to end of playlist." fi
Audio Player in gPodder preferences is set to this:
/home/christopher/bin/mpcut.sh %F
I have an application shortcut Super-G set to this in xfce4-keyboard-settings:
env GTK_THEME=Adwaita-dark GPODDER_HOME=/home/christopher/.config/gPodder/ GPODDER_DOWNLOAD_DIR=/home/christopher/Music/Podcasts/ /usr/bin/gpodder
or you could use an alias:
alias gpodder='GTK_THEME=Adwaita-dark GPODDER_HOME=/home/christopher/.config/gPodder/ GPODDER_DOWNLOAD_DIR=/home/christopher/Music/Podcasts/ /usr/bin/gpodder --verbose'