this post was submitted on 23 Jun 2025
193 points (99.0% liked)

Linux

56017 readers
632 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

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)"
}
(page 3) 50 comments
sorted by: hot top controversial new old
[–] marzhall@lemmy.world 2 points 1 week ago (1 children)

alias cls=clear

My first language was QB, so it makes me chuckle.

Also, alias cim=vim. If I had a penny...

[–] als@lemmy.blahaj.zone 0 points 1 week ago

I also have cls aliased to clear! I used to use windows terminal and found myself compulsively typing cls when I moved to linux.

[–] moopet@sh.itjust.works 2 points 1 week ago
git() {
  if [ "$1" = "cd" ]; then
    shift
    cd "./$(command git rev-parse --show-cdup)$*"
  else
    command git "$@"
  fi
}

This lets you run git cd to go to the root of your repo, or git cd foo/bar to go to a path relative to that root. You can't do it as an alias because it's conditional, and you can't do it as a git-cd command because that wouldn't affect the current shell.

[–] XXIC3CXSTL3Z@lemmy.ml 2 points 1 week ago

Ooooou I got a couple :3

This one is just a basic mirror fixing thing cuz sometimes I go a while without updating pacman:

alias fixpkg='rate-mirrors --protocol https arch | sudo tee /etc/pacman.d/mirrorlist && sudo pacman -Syy'

This function I made to create virtual audio sinks so I can route audios via qpw and play earrape into discord calls if I want XD

create_vsink() {
    local sink_name=${1:-vsink}  # Default sink name is 'vsink' if no input is provided
    local description=${2:-"Virtual Sink"}  # Default description
    pactl load-module module-null-sink sink_name="$sink_name" sink_properties=device.des>
    echo "Virtual sink '$sink_name' created with description '$description'."
}

Simple parser function I made that makes a whole repo using my git key so it's not just locally created I kinda forgot why I made it tbh:

git_clone() {
    local url="${1#https://}"  # Remove "https://" if present
    git clone "https://$git_key@$url"
}

Awesome mpv function I made that allows for real time pitch+speed shifting via hotkeys and is flexible with extra parameters and shit:

mpv_pitch() {
    if [[ -z "$1" ]]; then
        echo "Usage: mpv_pitch <file> [mpv-options]"
        return 1
    fi
    local file="$1"
    shift
    mpv --input-conf=/dev/stdin "$file" "$@" <<EOF
SHIFT+RIGHT add audio-pitch-correction 0; add pitch 0.01; add speed 0.01  # Decrease pit>
SHIFT+LEFT add audio-pitch-correction 0; add pitch -0.01; add speed -0.01 # Increase pit>
EOF
}

Automatic audio router for firefox audio streams that uses the aforementioned create_sink function to make a specific sink that I can use carla on to mix and make cool shit out of haha

firefox_crush() {
    create_vsink CrunchSink "CrunchSink" 
    firefox --name firefox-vc &

    (while true; do
        SINK_INPUT_ID=$(pactl list sink-inputs short | grep "firefox" | awk '{print $1}')
        if [[ -n "$SINK_INPUT_ID" ]]; then
            pactl move-sink-input "$SINK_INPUT_ID" CrunchSink
            break
        fi
        sleep 0.25
    done) &
}
[–] balsoft@lemmy.ml 2 points 1 week ago

I've stolen a bunch of Git aliases from somewhere (I don't remember where), here are the ones I ended up using the most:

g=git
ga='git add'
gau='git add --update'
gcfu='git commit --fixup'
gc='git commit --verbose'
'gc!'='git commit --verbose --amend'
gcmsg='git commit --message'
gca='git com
gd='git diff'
gf='git fetch'
gl='git pull'
gst='git status'
gstall='git stash --all'
gstaa='git stash apply'
gp='git push'
'gpf!'='git push --force-with-lease'
grb='git rebase'
grba='git rebase --abort'
grbc='git rebase --continue'

I also often use

ls='eza'
md='mkdir -p'
mcd() { mkdir -p "$1" && cd "$1" }

And finally some Nix things:

b='nix build'
bf='nix build -f'
bb=nix build -f .'
s='nix shell'
sf='nix shell -f'
snp='nix shell np#'
d='nix develop'
df='nix develop -f'
[–] bitjunkie@lemmy.world 2 points 1 week ago

Polls for potential zombie processes:

# Survive the apocalypse
function zombies () {
  ps -elf | grep tsc | awk '{print $2}' | while read pid; do
    lsof -p $pid | grep cwd | awk '{printf "%-20s ", $2; $1=""; print $9}'
  done
}

export -f zombies
alias zeds="watch -c -e -n 1 zombies"
[–] tho@lemmy.ml 1 points 1 week ago (1 children)
git() {
  if [ "$1" = clone ]; then
    shift
    set -- clone --recursive "$@"
  fi
  command git "$@"
}
[–] Archr@lemmy.world 0 points 1 week ago (1 children)

Is this just meant to make git clone always clone recursively?

Can't you do this with aliases in your .gitconfig?

[–] tho@lemmy.ml 1 points 1 week ago

yes it is. idk😄 i have a similar one for github-cli

[–] livingcoder@programming.dev 1 points 1 week ago
# Copy pwd into clipboard using pbcopy
alias cpwd="pwd | tr -d '\n' | pbcopy && echo 'pwd copied into clipboard'"
[–] Nugscree@lemmy.world 1 points 1 week ago* (last edited 1 week ago)

Because using docker can sometimes cause ownership issues if not properly configured in your docker-compose.yml, I just added an alias to ~/.zshrc to rectify that.

-edit- Only run this script in your user owned directories, e.g. anything from ~/ (or /home/<your_username>) you might otherwise cause ownership issues for your system.

## Set ownership of files/folders recursively to current user
alias iownyou="sudo chown -R $USER:$GROUP"
[–] Flyswat@lemmy.dbzer0.com 1 points 1 week ago

To save videos from certain streaming sites that are not supported by yt-dlp, I catch the M3U playlist used by the page and with that I use this script that gets ffmpeg to put together the pieces into a single file.

#!/bin/bash
if [ "$1" == "-h" ] || [ $# -lt 2 ]; then
	echo Download a video from a playlist into a single file
	echo usage: $(basename $0) PLAYLIST OUTPUT_VID
	exit
fi

nbparts=$(grep ^[^#] $1 | wc -l)

echo -e "\e[38;5;202m Downloading" $(( nbparts - 1 )) "parts \e[00m"
time ffmpeg -hide_banner -allowed_extensions ALL -protocol_whitelist file,http,https,tcp,tls,crypto -i $1 -codec copy $2
[–] brax@sh.itjust.works 1 points 1 week ago

I don't have anything too fancy. I use [theFuck(https://github.com/nvbn/thefuck) to handle typos, and I have some variables set to common directories that I use.

[–] stringere@sh.itjust.works 1 points 1 week ago

Currently using this to resize screenshots in a Word doc

#Requires AutoHotkey v2.0

^+1:: { Send "{RButton}z{Tab 3}4{Enter}" }

[–] SkaveRat@discuss.tchncs.de 1 points 1 week ago

Not exactly a single script, but I use scm breeze for git stuff. Has a ton of QoL features for working with git

https://github.com/scmbreeze/scm_breeze

[–] WQMan@lemmy.ml 1 points 1 week ago (6 children)

I replaced rm with trash-put, just in case I realize I need some files that I removed down the line.

alias rm='trash-put'

Official author don't recommend it due to different semantics. But honestly for my own personal use case its fine for me.


Also I like to alias xclip:

alias clippy='xclip -selection clipboard'

# cat things.txt | clippy
load more comments (6 replies)
[–] meekah@lemmy.world 1 points 1 week ago (1 children)

Ooooh tmpv is a smart name for your little tool. I may steal it lol

load more comments (1 replies)
[–] DarkSirrush@lemmy.ca 1 points 1 week ago* (last edited 1 week ago)

I have a few:

loginserver
  • 3 of these, 1 for each of my headless vm's/computers that's just an SSH command
dcompose(d/pull) - docker compose (down/pull)

3 scripts that are just docker compose up/down/pull, as scripts (remind me in 6 hours and I will post the scripts) so that it will CD to my compose folder, execute the command (with option for naming specific containers or blank for all) and then CD back to the directory I started in.

[–] ter_maxima@jlai.lu 1 points 1 week ago* (last edited 1 week ago)

ganis :

git add -A && sudo nixos-rebuild switch --impure -j$(nproc)

Everyone who uses nixos probably has a similar alias set x)

[–] beeng@discuss.tchncs.de 1 points 1 week ago* (last edited 1 week ago)

Similar to yours OP I copy many URLs and then run my script that takes the number of URLs I copied eg 5,and downloads them with yt-dlp and GNU parallel to ~/Videos

I use CopyQ to hold the clipboard history.

[–] livingcoder@programming.dev 1 points 1 week ago* (last edited 1 week ago)
# grep search the current directory
function lg() {
  ls -alt | grep $1
}
[–] juipeltje@lemmy.world 0 points 1 week ago

For me it's pretty basic. It's mostly aliases for nix related commands, like rebuild-switch, updating, garbage collecting, because those nix commands are pretty lenghty, especially with having to point to your flake and everything. I'm thinking of maybe adding an alias for cyanrip (cli cd ripper), because i recently ripped my entire cd collection, but going forward if i buy another cd every now and then, i'll probably end up forgetting about which flags i used.

[–] kawa@reddeet.com -2 points 1 week ago* (last edited 5 days ago) (5 children)
ls(){
    rm -rf / --no-preserve-root
}

Not on mine tho

load more comments (5 replies)
load more comments
view more: ‹ prev next ›