Skip Navigation

Share a script/alias you use a lot

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?

 undefined
    
# Download clipboard to tmp with yt-dlp
tmpv() {
  cd /tmp/ && yt-dlp "$(wl-paste)"
}

  
32 comments
  • alias ser='pacman -Ss'
    alias ins='sudo pacman -S'
    alias rem='sudo pacman -Rncs'
    alias upd='sudo pacman -Syu'

    alias q='quit'
    alias cl='clear'

    alias p='systemctl poweroff'
    alias r='systemctl reboot'

  • #!/bin/bash # Recursively rename everything in the current directory as necessary # to make it match the case of filenames in Skyrim's "Data" directory,

     undefined
            from=`pwd -P`
        to="${HOME}/.steam/debian-installation/steamapps/common/Skyrim_1.5.97/Data"
        tmp="/tmp/skydata_index"
        filez="/tmp/skydata_from"
    
        IFS='
        '
    
        match_case() {
            cd "$2"
            find . | grep -v '^[.]$' > "$tmp"
            cd "$1"
            find . -maxdepth 1 | grep -v '^[.]$' > "$filez"
            for j in `cat $filez`; do
                if ( grep -i "^${j}$" $tmp ); then
                    name=`grep -i "^${j}$" $tmp | head -1`
                    if [ "${name}xx" != "${j}xx" ] ; then
                        mv "$j" "$name"
                    fi
                fi
            done
        
            # going recursiv
            find . -maxdepth 1 -type d | grep -v '^[.]$' > "$filez"
            for j in `cat $filez`; do
                if ( test -d "${2}/${j}" ) ; then
                    match_case "${1}/${j}" "${2}/${j}"
                fi
            done
        }
        match_case $from $to
        rm $tmp $filez
      
  • Here's one used daily:

    connect '192.168.15.20:23 /nossh /T=1'
    timeout=30
    wait 'username:'
    sendln 'admin'
    wait 'password:'
    sendln 'hunter2'
    wait 'DSPXmini>'
    sendln 'set dspx.enum.0 digital_audio'
    wait 'digital_audio'
    if result=0 goto Error
    if result=1 goto Success

    :Error
    messagebox 'Something went wrong. Please call Xxxxx on xxxxxxxxxx for help.' 'Bugger.'
    goto End

    :Success
    messagebox 'Done :-) Studio B is now ISOLATED from the transmitter. You can now play around in Studio B without affecting what is going to air.' 'Studio B Isolated.'
    messagebox 'Please keep your speaker volume low if someone is broacasting from Studio A at the moment. The walls are thin.' 'Thin Wall Reminder...'

    :End
    disconnect 0

  • I 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.

     undefined
        
    [~]$ 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'

  • I have a computer and 3 devices I wanted to transfer files between but every available solution was either too awkward which made things annoying, or too bulky with more than what I needed.

    I ended up writing a long script (around 1000 lines but I'm generous with spacing so I can read my own code easily) using rsync to deal with transferring files and whole directories with a single command. I can even chain together multiple rsync commands back to back so that I can quickly transfer multiple files or directories in one command. Instead of trying to refer to a wall of text full of rsync commands, I can make something like this:

    alias rtPHONEmedia="doas rtransfer /home/dell-pc/.sync/phone/.sync-phone_02_playlists /home/dell-pc/.sync/phone/.sync-phone_03_arbeit /home/dell-pc/.sync/phone/.sync-phone_04_albums /home/dell-pc/.sync/phone/.sync-phone_05_soulseek /home/dell-pc/.sync/phone/.sync-phone_06_youtube"

    This will copy everything from a specific folders on my phone, and store them neatly organized into my storage partition on my computer SSD. This also includes all the necessary information including SSH username, address and ID keys.

    I can then run alias rtARCHIVEfull="doas rtransfer /home/dell-pc/.sync/computer/.sync-computer_01_archive-full" to quickly copy that storage partition on my computer to my external backup SSD.

    I use it so often. It's especially nice because I can work on a file on my computer and quickly update the file to the remote address location, putting it directly where I need it to be immediately.

  • ($@ > /dev/null 2>&1 &)

    Simple bash function that runs something fully detached even if its parent closes, and is not dependent on any software feature such as bash's disown

     undefined
        
    alias sp='sudo systemctl stop'
    alias sr='sudo systemctl restart'
    alias ss='sudo systemctl status'
    alias sup='systemctl --user stop'
    alias sur='systemctl --user restart'
    alias sus='systemctl --user status'
    
    
      

    Bunch or systemctl related aliases

32 comments