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)"
}
  • melimosa@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    5 days ago

    I try to organise my data in the cleanest way possible, with the less double possible etc… I end up using a lot of symbolic links. When doing maintenance, sometimes I want to navigate in the “unlogical” way the data are organized, but the PWD variable is not necessarily very cooperative. This alias is really useful in my case :

    alias realwd='cd -P .'  
    

    Here is an example :

    $ echo $PWD  
    /home/me  
    $ cd Videos/Torrents/  
    $ echo $PWD  
    /home/me/Videos/Torrents  
    $ realwd  
    $ echo $PWD  
    /home/me/data/Torrents/Video  
    

    I also do some X application, compositor and WM development, and I have a few aliases to simplify tasks like copying from an Xorg session to an Xnest (and the other way around), or reload the xrandr command from my .xinitrc without duplicating it.

    alias screenconf='$(grep -o "xrandr[^&]*" ~/.xinitrc)'  
    alias clip2xnext='xclip -selection clip -o -display :0 | xclip -selection clip -i -display :1'  
    alias clip2xorg='xclip -selection clip -o -display :1 | xclip -selection clip -i -display :0'  
    

    I have an alias for using MPV+yt-dlp with my firefox cookies :

    alias yt="mpv --ytdl-raw-options='cookies-from-browser=firefox'"  
    

    I can’t stand too long lines of text on my monitor, particularly when reading manpages, so I set the MANWIDTH env variable.

    # Note : if you know that *sometimes* your terminal will be smaller than 80 characters  
    # refer to that https://wiki.archlinux.org/title/Man_page  
    export MANWIDTH=80  
    

    I use null-pointers a lot, with a shorthand.

    # Note: env.sh actually provide other helpful aliases on their homepage  
    function envs.sh() {  
    	if [ $# != 1 ]; then  
    		1>&2 printf "Error, need one argument.\n"  
    		return 1  
    	fi  
    	curl -F'file=@'"$1" https://envs.sh/  
    }  
    

    The usual fake editor in my path, so that browsers and other applications open Vim the correct way.

    #!/bin/sh  
    # st_vim.sh - executable in my ~/.local/bin  
    # for example in firefox's about:config :  
    #   - view_source.editor.path : set to the value of $(which st_vim.sh)  
    #   - view_source.editor.external : set to true  
    
    st -- $EDITOR "$*"  
    

    My .xinitrc is quite classical, I still have this in it (setup for dwm’s title bar, people usually install much complicated programs) :

    while true; do xsetroot -name "$(date +"%d %H:%M")"; sleep 60; done &  
    

    I also have a lot of stupid scripts for server and desktop maintenance, disks cleaning etc… those are handy but are also very site-specific, let me know if your interested.

    • Revan343@lemmy.ca
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      alias sl='ls | while IFS= read -r line; do while IFS= read -r -n1 char; do if [[ -z "$char" ]]; then printf "\n"; else printf "%s" "$char"; sleep 0.05; fi; done <<< "$line"; done'

      I can’t easily check if it works until I get home to my laptop, but you get the idea

      • melimosa@piefed.blahaj.zone
        link
        fedilink
        English
        arrow-up
        2
        ·
        5 days ago

        That’s very good.

        Generalization and line feed customisation :

        function sloooower() {
        	BASE_INTERVAL=${1:-0.05}
        	RET_ADD_INTERVAL=${2:-0.1}
        	CHAR_ADD_INTERVAL=${3:-0}
        	while IFS= read -r -n1 char; do
        		if [[ -z "$char" ]]; then
        			sleep "${RET_ADD_INTERVAL}"
        			printf "\n"
        		else
        			sleep "${CHAR_ADD_INTERVAL}"
        			printf "%s" "$char"
        		fi
        		sleep "${BASE_INTERVAL}"
        	done
        }
        alias sl='ls | sloooower'
        
    • thingsiplay@beehaw.org
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      With how many new Linux users we get recently, I don’t like this joke at all without a disclaimer. Yes yes, its your own fault if you execute commands without knowing what it does. But that should not punish someone by deleting every important personal file on the system.

      In case any reader don’t know, rm is a command to delete files and with the option rm -r everything recursively will be searched and deleted on the filesystem. Option -f (here bundled together as -rf) will never prompt for any non existing file. The / here means start from the root directory of you system, which in combination with the recursive option will search down everything, home folder included, and find every file. Normally this is protected todo, but the extra option --no-preserve-root makes sure this command is run with the root / path.

      Haha I know its funny. Until someone loses data. Jokes like these are harmful in my opinion.