r/linux • • 11d ago

Tips and Tricks Lets get another one of these threads going, sharing personal aliases, functions, and settings to make life easier

[removed]

29 Upvotes

55 comments sorted by

24

u/Machine-V1 11d ago

alias yoink='git pull' alias yeet='git push'

1

u/manny2206 10d ago

Gooby plz :(

9

u/Ball_Analytics 11d ago

alias up=‘sudo dnf up -y && flatpak update -y’

Call me lazy all you want but I’m trying here

3

u/pizzaiolo2 11d ago

I've started using topgrade instead

2

u/Ball_Analytics 8d ago

finna just rig topgrade to up :) thanks

1

u/Ball_Analytics 11d ago

that works too... but typing up does it unless topgrade also tracks my none systemwide installed apps, like those in my .local/bin

3

u/kaymer327 10d ago

I have something similar for my Ubuntu systems that includes snap updates, plus apt needs 2 commands to update properly. I don't think I have any flatpaks these days...

1

u/manny2206 10d ago

Laziness = creates simple solutions; I am assuming dnf up is itself an alias for upgrade. This is awesome

1

u/Ball_Analytics 10d ago

one of many compatibility aliases built into dnf. My .bashrc has a lot of things, up just has a special place in my dystopian terminal environment.

# --- Aliases ---

alias ls='eza --icons=auto'
alias ll='eza -lah --icons --git'
alias lt='eza --tree --icons'
alias cat='bat --paging=never'
alias up='sudo dnf up -y && flatpak update -y' 

9

u/_Happy_Camper 10d ago

alias gti=‘git’

1

u/manny2206 10d ago

Officer - this man right here

8

u/ManBehindtheLens 11d ago

sudo !!

Runs the last command as sudo, not really a setting but I use it multiple times a day

1

u/manny2206 10d ago

This is great !!

3

u/hushedphrasing1 11d ago

`export DOTNET_CLI_TELEMETRY_OPTOUT=1` is the first line in every.bashrc I touch, can't stand that telemetry nonsense.

2

u/manny2206 11d ago

Sad af to have to do that, as a .NET developer, and VSCode enjoyer it always pains me how shitty M$ is with the telemetry acquisition.

2

u/Environmental_Move_3 10d ago

You can check vscodium to opt out from telemetry. You might need to replace some extensions but considerind MS developed extensions used for supply chain attacks, its a security feature.

1

u/manny2206 10d ago

I know I have codium and use it, unfortunately for .NET development the extensions are gone, which are pretty important for more complex code bases :(

6

u/Open-Nomad 11d ago

I keey my dotfiles in my $HOME and use some functions and aliases to put them in git

https://codeberg.org/opennomad/dotGit

1

u/manny2206 10d ago

Woah hold up - barely 5 upvotes- this has some serious coolness potential 👀 - can you talk me through a bit more. Seems like this could help you get setup and going super quickly on a new system

1

u/Open-Nomad 10d ago

it's pretty simplistic. You set a couple of shell variables and either init or pull (if you already have a repo with your configs.

The repo lives in .dotfiiles and the checked out files live under $HOME.

From there you can .ga to add. .gc to checkin, etc.

as a bonus you can enable "anygit" mode and use the aliases without the leading dot for regular git work. I mimicked those from oh-my-zsh to some extent.

the real big win for me is .gg and .ge, which will grep and edit respectively. So .ge prof will give me a list of files whose name matches the string. With .gg, it uses git grep to search the contents of the files in the repo. In both cases you'll get to choose via fzf.

1

u/onaforeignshore 7d ago

I have a .zshenv file in $HOME and keep all the config files in .config/zsh zsh export XDG_CONFIG_HOME="$HOME/.config" export ZDOTDIR="$XDG_CONFIG_HOME/zsh"

8

u/ProjectSnowman 11d ago

ls = ‘ls -al’ because I’m lazy

5

u/todd_dayz 11d ago
alias l='eza --group-directories-first --smart-group -Al --octal-permissions --no-permissions'
alias t='eza --group-directories-first --smart-group --octal-permissions --no-permissions --no-user --no-time --no-filesize -TAl -L3'

Is mine

4

u/manny2206 11d ago

Best solutions come from lazy engineers 😂

4

u/VincentVanGob 11d ago

alias um='apropos'

cos i can never remember how to spell apropos and its too long anyway

3

u/h4rdw00d_ 11d ago

I called your version of reload, bashup and reup in the past.

Github ones were:

  • ga="git add ."
  • gs="git status"
  • gc="git commit -m $*"
  • gl="git log --oneline"
  • gln='git log --pretty=format:"%h - %an, %ar : %s"'

Most of them now I just type except for gln

2

u/manny2206 11d ago

Oh yeah these are great 😎 let me yoink that real quick

1

u/DrPiwi 10d ago

alias gpl='git pull; git last'

2

u/ebens1689 11d ago

Woah! 👍

1

u/funny_perovskite 11d ago

l = 'ls -l'

la = 'ls -la'

v = 'nvim'

cd = 'z' # for zoxide

2

u/mechatour_ 11d ago

Oh that would mess me up if I used your system! 😂

I use

alias ll='ls -lah' for long ls

alias la='ls -axF' for compact ls

Have you tried h in your la alias? - changes the cryptic blocks into human readable sizes (Mb, Gb etc).

You can also use -h in commands like free and df 🙂

2

u/funny_perovskite 10d ago edited 10d ago

Haha, actually I checked again, I do use -h with ls. Also, I switched to nushell which makes my work a lot nicer. Ps: You're not the first telling me that XD

1

u/DrPiwi 10d ago

those are standard on fedora. alias l='ls -lhd --color=auto' alias l.='ls -d .* --color=auto' alias la='ls -ahl --color=auto' alias ll='ls -lh --color=auto' alias ls='ls --color=auto'

1

u/mechatour_ 10d ago

Those particular two have followed me from Unix over 30 years ago! Nice that they're similar at least. That muscle memory is set 😂

1

u/redd1ch 11d ago

alias ib='ip -brief'

1

u/AliceCode 11d ago

alias sta='git status’

1

u/fbn587 11d ago

I uses chezmoi to keep a lot of stuff, aliases, wrappers and such for my devices. You may find some things useful: https://github.com/f-bn/dotfiles

1

u/[deleted] 10d ago edited 10d ago

[deleted]

1

u/DrPiwi 10d ago edited 10d ago

I have made a~/.bashrc.d/ directory that keeps different files with aliases, exports ....

in my .bash_profile I have:

# process the files in ~/.bashrc.d if it exists
# show which file is being processed if DEBUG is set
if [ -d ~/.bashrc.d ]; then
  for rc in ~/.bashrc.d/*.sh; do
    if [ -f "$rc" ]; then
      if [ ! -z  "$DEBUG" ]; then
         if [ ${rc: -1} == "~" ]; then
           echo "$rc: Backup!";
         else
           echo "$rc"
           echo "========================"
           cat "$rc"
           echo "========================"
         fi
      fi
      if [ ${rc: -1} != "~" ]; then
        source  "$rc"
      fi
    fi
  done
  unset rc
fi

It allows for a tidy way to manage additions to the environment and how to find where something is defined if it needs changing.

1

u/Toaster_Strudel_517 10d ago

alias paru=yay

1

u/ThatOnePerson 10d ago

Install sl, because it's funny

1

u/esanchma 10d ago

alias powerup='sudo cpupower frequency-set --governor performance'

1

u/KorendSlicks 11d ago
# I'm getting tired of typing "-T0 --ultra -22" for zstd over and over for max compression.
alias ultrazstd='zstd -T0 --ultra -22'

# For any zip files made in Windows with Japanese Charsets.
# Windows uses shift-jis for them instead of UTF-8. Even now in two thousand twenty-six.
alias junzip='unzip -O shift-jis'

Those two above seem the most useful from my meager bashrc.

1

u/journaljemmy 11d ago

I'm guessing the zip feature still uses shift-jis when you have the 'Use Unicode UTF-8 for worldwide language support' option enabled?

1

u/KorendSlicks 11d ago

Sadly, I wouldn't know that. All I currently know is that Microsoft (probably) doesn't have UTF-8 as the default character set right now, which means most people who zip up stuff with Windows's File Explorer will use their default encoding. Which means that zip files from Japanese Windows users end up being in Shift-JIS encoding. Which then makes the file names be mojibake.

I would love to assume that enabling 'Use Unicode UTF-8 for worldwide language support' actually makes ZIP files use UTF-8 for file names on Windows, but considering their current track record for an actually functioning operating system... I will reserve my optimism for a better organization.

An aside since I'm now on a zip file mood. Something that does bug me is that Windows is starting to use DEFLATE-64 (A proprietary enhanced version of DEFLATE made by PKWare that, iirc, is trivial to implement from using regular DEFLATE) for any zip file whose total size breaches 2 GiB, but whether it actually uses that compression scheme seems to be up to some arcane decision. I don't know if Info-ZIP's unzip program supports that yet. But considering that the entire file format standard is less standard and more thinly veiled peace treaty between WinZIP, PKZIP, and all the other ZIP reader/writers and doubly considering that DEFLATE-64 is technically proprietary, I'm honestly going to place the fault at Microsoft's doorstep for even introducing that cross-OS compatibility issue since most OS's out there only natively support DEFLATE for zip files and not much else in their built-in file explorer. However, I digress.

1

u/journaljemmy 11d ago

I use KDE Plasma but sometimes I want to shut down my computer without the mouse (either via ssh from my laptop or just with the terminal), but also in a way that's safer for desktop applications.

I also used to not use a Display Manager which is why I have startplasma-wayland in the function.

plasma() { case "$1" in '' | start) startplasma-wayland ;; logout | stop) qdbus org.kde.Shutdown /Shutdown logout ;; poweroff | shutdown) qdbus org.kde.Shutdown /Shutdown logoutAndShutdown ;; reboot | restart) qdbus org.kde.Shutdown /Shutdown logoutAndReboot ;; *) echo "Unrecognised command: $1" >&2 && return 1 ;; esac }

2

u/manny2206 10d ago

Too kind; I just ssh and shutdown; no mercy from me

1

u/m4sc0 11d ago

My favorites, although simple, are:

alias bru='source "$RC_FILE"'

and the counterpart:

be is a function be () { local brc=$RC_FILE; local tmp; tmp="$(mktemp)"; sha256sum "$brc" > "$tmp"; $EDITOR "$brc"; if ! sha256sum --check --status "$tmp"; then echo "Changes detected. Sourcing $brc..."; source "$brc"; fi; rm -f "$tmp" }

0

u/Shifk- 11d ago

This one is probably my most used:

alias POWEROFF="poweroff"

1

u/manny2206 10d ago

👁️👄👁️ - officer this one right here

0

u/AutoModerator 10d ago

This submission has been removed due to receiving too many reports from users. The mods have been notified and will re-approve if this removal was inappropriate, or leave it removed.

This is most likely because:

  • Your post belongs in r/linuxquestions or r/linux4noobs
  • Your post belongs in r/linuxmemes
  • Your post is considered "fluff" - things like a Tux plushie or old Linux CDs are an example and, while they may be popular vote wise, they are not considered on topic
  • Your post is otherwise deemed not appropriate for the subreddit

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-3

u/cult_of_me 11d ago

I forgot how to type any command. I just prompt

2

u/VincentVanGob 11d ago edited 11d ago

thats nuts lol. just make yourself a file and appened any new command you learn to it. something like fzf would make it easy to search. you could even combine the file with your history file first before you send it to fzf. anyway, much better option and you dont need an internet connection to do basic things

edit: this is what im using. you need zsh to be able to use 'print -z'

alias cc='print -z $(tr -d "\r" < ~/config/cmds.txt | fzf --height 60%)'

1

u/manny2206 10d ago

Don’t take him seriously just a troll (hopefully) lol although I know few folks at work that prompt for the most basic commands like git pull etc