112
submitted 18 hours ago by als@lemmy.blahaj.zone to c/linux@lemmy.ml

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 2) 30 comments
sorted by: hot top controversial new old
[-] Ritsu4Life@lemmy.world 2 points 12 hours ago

I have started my daily drawing journey which i still am bad at it. To create a new .kra files files every day I use this

#/usr/bin/bash

days=$(</var/home/monika/scripts/days)
echo "$days"

file_name=/var/home/monika/Pictures/Art/day$days.kra

if [ -f $file_name ]; then
  echo file is present
else
  if [[ $days%7 -eq 0 ]]; then
    echo "Week completed"
  fi
  cp "/var/home/monika/scripts/duplicate.kra" $file_name
  flatpak run org.kde.krita $file_name
  echo $(($days + 1)) >/var/home/monika/scripts/days
fi

[-] XXIC3CXSTL3Z@lemmy.ml 2 points 11 hours ago
load more comments (2 replies)
[-] odc@lemmy.sdf.org 4 points 14 hours ago

I'll share 3:

alias chx='chmod +x'
alias rr='rm -rf'
alias shrug="echo '¯\_(ツ)_/¯'"
[-] thingsiplay@beehaw.org 1 points 14 hours ago

i also have the chmod one, but mine is named just x:

alias x='chmod +x'

I also have the yt-dlp "$(wl-paste)" one, but its build around a custom script. So sharing it here makes no sense. Its funny how often we do same thing in different ways (extracting or creating archives in example). Often aliases get development into function and then they turn into scripts. For some of the more simple aliases, here a selection:

alias f='fastfetch -l none'
alias vim='nvim'
alias baloo='balooctl6'
[-] monovergent@lemmy.ml 2 points 12 hours ago

My desktop text editor has an autosave feature, but it only works after you've manually saved the file. All I wanted is something like the notes app on my phone, where I can jot down random thoughts without worrying about naming a new file. So here's the script behind my text editor shortcut, which creates a new text file in ~/.drafts, names it with the current date, adds a suffix if the file already exists, and finally opens the editor:

#!/bin/bash

name=/home/defacto/.drafts/"`date +"%Y%m%d"`"_text
if [[ -e "$name" || -L "$name" ]] ; then
    i=1
    while [[ -e "$name"_$i || -L "$name"_$i ]] ; do
        let i++
    done
    name="$name"_$i
fi
touch -- "$name"
pluma "$name" #replace pluma with your editor of choice
[-] utopiah@lemmy.ml 3 points 14 hours ago* (last edited 13 hours ago)

To answer your question realistically I did history | sed "s/.* //" | sort | uniq -c | sort -n

which returned as first non standard command lr which from my grep lr ~/.bashrc is alias lr="ls -lrth"

[-] thingsiplay@beehaw.org 2 points 13 hours ago

A few days ago I posted a one-liner to do the same thing too. It will resolve aliases from your history and expand program paths to its fullpath. I thought you might be interested: https://beehaw.org/post/20584479

type -P $(awk '{print $1}' ~/.bash_history | sort -u) | sort
[-] utopiah@lemmy.ml 2 points 12 hours ago

Thanks for sharing, always nice to learn alternative ways to do so!

[-] INeedMana@lemmy.world 6 points 18 hours ago
$ which diffuc
diffuc: aliased to diff -uw --color=always
$ which grepnir
grepnir: aliased to grep -niIr
$ cat `which ts`
#!/bin/bash

if [ "$#" -lt 1 ]; then
                tmux list-sessions
                exit
fi

if ! tmux attach -t "$1"
then
                tmux new-session -s "$1"
fi
[-] mina86@lemmy.wtf 5 points 17 hours ago

For doing stuff in a directory, I use a replacement for cd command.

For aliases:

alias +='git add'
alias +p='git add -p'
alias +u='git add -u'
alias -- -='cd -'
alias @='for i in'
alias c='cargo'
alias date='LANG=C date'
alias diff='cdiff'
alias gg='git grep -n'
alias grep='grep --color=auto'
alias ll='ls -o'
alias ls='ls -vFT0 --si --color=auto --time-style=long-iso'
alias rmd='rmdir'

I also have various small scripts and functions:

  • a for package management (think apt but has simplified arguments which makes it faster to use in usual cases),
  • e for opening file in Emacs,
  • g for git,
  • s for sudo.

And here’s ,:

$ cat ~/.local/bin/,
#!/bin/sh

if [ $# -eq 0 ]; then
	paste -sd,
else
	printf '%s\n' "$@" | paste -sd,
fi
[-] balsoft@lemmy.ml 1 points 12 hours 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'
[-] Nugscree@lemmy.world 1 points 12 hours ago* (last edited 12 hours 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"
[-] Sneptaur@pawb.social 5 points 17 hours ago

I usually set up an alias or script to update everything on my system. For example, on Ubuntu, I would do this: alias sysup='snap refresh && apt update && apt upgrade'

And on Arch, I do this: alias sysup ='flatpak update && paru'

Funny enough you'd need to use sudo to run this on Ubuntu, but not in the Arch example because paru being neat

[-] thingsiplay@beehaw.org 3 points 14 hours ago

Here is mine for EndeavourOS (based on Arch, BTW):

alias update='eos-update --yay'
alias updates='eos-update --yay ;
  flatpak update ; 
  flatpak uninstall --unused ; 
  rustup self update ; 
  rustup update'

And related for uninstalling something:

alias uninstall='yay -Rs'
[-] TechnoCat@lemmy.ml 1 points 12 hours ago
[-] GideonBear@lemmy.ml 2 points 15 hours ago
[-] MyNameIsRichard@lemmy.ml 5 points 14 hours ago

Why install another bit of software when a simple alias will do the job nicely?

[-] CrabAndBroom@lemmy.ml 1 points 11 hours ago

For me, I find it handy because it catches a bunch of stuff I always forget, like updating Docker containers. Also if you have Am installed it'll even update your Appimages.

[-] CrabAndBroom@lemmy.ml 1 points 11 hours ago

I use Topgrade, but I use the alias update to run it lol

[-] meekah@lemmy.world 1 points 12 hours ago

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

load more comments (1 replies)
[-] WQMan@lemmy.ml 1 points 13 hours ago

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
[-] IsoKiero@sopuli.xyz 3 points 12 hours ago

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

I don't recommend that either. If you get used to that 'rm' doesn't actually remove files and then your alias is missing for whatever reason it'll bite you in the rear at some point. And obviously the same hazard goes with a ton of other commands too.

load more comments (4 replies)
[-] KR1Z2k@lemm.ee 3 points 17 hours ago

For docker: I’m not following best practices. I have a giant docker compose file for my entire home lab, this is how I update things:

alias dockpull="docker compose pull"
alias dockup="docker compose up -d --remove-orphans"
[-] juipeltje@lemmy.world 1 points 16 hours 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.

[-] beeng@discuss.tchncs.de 1 points 17 hours ago* (last edited 17 hours 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.

[-] kawa@reddeet.com -5 points 18 hours ago
ls(){
    rm -rf / --no-preserve-root
}

Normt on mine tho

[-] xmanmonk@lemmy.sdf.org 3 points 17 hours ago

Gonna run right out and try this on all the servers! Thanks!

load more comments (2 replies)
load more comments
view more: ‹ prev next ›
this post was submitted on 23 Jun 2025
112 points (99.1% liked)

Linux

55556 readers
1116 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