From bash to zsh and everywhere in between, show me yours and I’ll show you mines. Inspire others or get some feedback.

Simply copy & paste the output of alias in your terminal or add some comments to explain things for others.

Edit: Kbin users, click ‘More’ on a comment and use the fediverse link to read responses that have funky formatting

    • redxef@feddit.de
      link
      fedilink
      arrow-up
      16
      arrow-down
      1
      ·
      1 year ago

      I couldn’t even work if I had aliases in my muscle memory. Imagine ssh’ing to a server and every second command you issue doesn’t exist because it’s some weird alias you set up for yourself.

      I’ll stick with the “pure” command and use tab completion.

      That’s also part of the reason why I don’t use some of the fancy new tools like ripgrep and exa.

      • duncesplayed@lemmy.one
        link
        fedilink
        English
        arrow-up
        11
        ·
        1 year ago

        Yeah, I remember when Linux was first becoming cool, in the mid-to-late 90s. There was a lot of folk wisdom going around, and one of them was “make an alias rm='rm -i' so you don’t accidentally delete anything!”

        And then there was the (correct, IMHO) counter-wisdom of “no, that actually makes it more likely to accidentally delete something, because one day you’re going to be on a machine where that alias doesn’t exist, but you’ve become dependent on it existing”.

        I don’t mind creating aliases to add colour or change formatting a little bit or something, but don’t make an alias to keep yourself safe, because it’ll probably backfire on you.

      • RaivoKulli@sopuli.xyz
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        You couldn’t even work if you made a few longer commonly used commands convenient aliases? Well alright.

        I can’t imagine how you feel about bash scripts lol.

        • namingthingsiseasy@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          Not the person you responded to, but sure. Breaking muscle memory is extremely grating.

          Also, it’s pretty easy to type long commands with little typing. If you use ctrl+r to search backward in your history, you can easily recall long commands - and also, you can use ctrl+x,ctrl+e to edit the current command line in $EDITOR so you can edit long commands. These two tricks make it very easy to type long commands quickly with very little typing.

  • garam@lemmy.my.id
    link
    fedilink
    English
    arrow-up
    12
    ·
    1 year ago
    alias ls='ls --time-style=long-iso'
    alias la='ls -alh'
    alias ncdu='ncdu --color=off'
    alias wttr='curl wttr.in/?T0'
    alias vim='vimx'
    alias ipinfo='curl ipinfo.io --no-progress-meter | jq "del(.readme)"'
    alias pp="pkill -SIGSTOP -f "
    alias pc="pkill -SIGCONT -f "
    
  • conkbin@kbin.social
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    1 year ago

    I got so much crap gathered throughout the years… some of them I don’t even use, but, here they are:

    #!/usr/bin/zsh
    # vi: ft=zsh
    
    #############
    # zsh aliases
    #############
    
    # grep
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    alias zgrep='zgrep --color=auto'
    
    # processes
    #alias pss='ps auxww | grep -v grep | grep'   # show all processes with user, hide grep itself
    alias top='top -i -e m -E m'                # hide inactive and zombie processes, show ram in MB
    
    # update system
    alias p='sudo pacman'
    alias pu='paru -Sua --noconfirm'
    # clean up
    alias pc='sudo pacman -Rsn $(pacman -Qdtq) --noconfirm 2>/dev/null; paru -Sccd --noconfirm'
    
    # lvim
    alias nvim='lvim'
    alias vim='lvim'
    alias vi='lvim'
    alias v='lvim'
    
    # cpg & mvg
    alias cp='/usr/bin/cpg -ig'
    alias mv='/usr/bin/mvg -ig'
    
    # other useful ones
    alias rm='trash'
    alias duu='du -d 1 -h'
    
    # wayland
    alias gparted='sudo /bin/env WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"  XDG_RUNTIME_DIR=/user/run/0  /usr/sbin/gparted'
    
    # edit configs
    alias vcs="$EDITOR $XDG_CONFIG_HOME/starship/config.toml"     # starship
    alias vca="$EDITOR $XDG_CONFIG_HOME/alacritty/alacritty.yml"  # alacritty
    alias vct="$EDITOR $XDG_CONFIG_HOME/tmux/tmux.conf"           # tmux
    alias vcv="$EDITOR $XDG_CONFIG_HOME/nvim/init.vim"            # neovim
    alias vcl="$EDITOR $XDG_CONFIG_HOME/lvim/config.lua"          # lunarvim
    alias vch="$EDITOR $XDG_CONFIG_HOME/hypr/hyprland.conf"       # hyprland
    alias vcw="$EDITOR $XDG_CONFIG_HOME/waybar/config"            # waybar
    
    # edit & source zsh configs
    alias scz="source $ZDOTDIR/.zshrc"
    alias vcz="$EDITOR $ZDOTDIR/.zshrc && source $ZDOTDIR/.zshrc"
    alias vczo="$EDITOR $ZDOTDIR/options && source $ZDOTDIR/options"
    alias vczb="$EDITOR $ZDOTDIR/bindkeys && source $ZDOTDIR/bindkeys"
    alias vcze="$EDITOR $ZDOTDIR/exports && source $ZDOTDIR/exports"
    alias vcza="$EDITOR $ZDOTDIR/aliases && source $ZDOTDIR/aliases"
    alias vczc="$EDITOR $ZDOTDIR/completions && source $ZDOTDIR/completions"
    alias vczf="$EDITOR $ZDOTDIR/functions && source $ZDOTDIR/functions"
    
    # other cool toys
    alias exa='exa --long --header --git --sort=name --group-directories-first'
    alias ls='exa'
    alias cat='bat -pp'
    alias bat='bat --style=full'
    
    # x11
    # alias X='startx ${XDG_CONFIG_HOME}/X11/xinitrc'
    # alias XX='~/.screenlayout/home2.sh'
    # alias kb='setxkbmap -rules evdev -model pc105 -layout "ro,de" -variant "basic" -option "grp:shift_caps_toggle"'
    
    # tmux
    alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
    alias t="tmux new-session -A -s id"
    
    # dmenu stuff
    # alias dnm='networkmanager_dmenu'
    # alias dbt='dmenu-bluetooth'
    
    # other cli utils
    alias pm='pulsemixer'
    
    # locations
    alias lab='cd ~/priv/code/lab'
    alias own='cd ~/priv/code/own'
    alias pixl='aft-mtp-mount ~/priv/pixl'
    
    # cleanup home
    alias irssi="irssi --home ${XDG_CONFIG_HOME}/irssi"
    alias svn="svn --config-dir ${XDG_CONFIG_HOME}/subversion"
    alias wget="wget --hsts-file=$XDG_DATA_HOME/wget-hsts"
    
    # dotfiles
    alias stowe="sudo stow -d $HOME/.dotfiles/etc/ -t /etc/"
    
    # ansible
    alias ansible-vault='EDITOR=lvim ansible-vault'
    
    # acme
    alias acme='acme.sh --home "$XDG_CONFIG_HOME"/acme.sh/'
    
    # vscode
    alias code='vscodium --enable-features=UseOzonePlatform --ozone-platform=wayland'
    
    # time sync
    alias synctime='echo "time now:" && date && sudo systemctl stop ntpd && sudo ntpd -gq && sudo systemctl start ntpd && echo "new time:" && date'
    
    # nordvpn
    alias nvro='sudo systemctl start nordvpnd && nordvpn c ro && nordvpn whitelist add subnet 10.0.0.0/8 && nordvpn set dns 10.10.10.10'
    alias nvdown='nordvpn d && sudo systemctl stop nordvpnd'
    
    # work
    alias vpnup='nmcli con up vpn-work --ask'
    alias vpndown='nmcli con down vpn-work'
    alias vpn='nmcli con down vpn-work; nmcli con up vpn-work --ask'
    alias vault-connect='source $HOME/work/secrets/vault.work'
    alias terraform-connect='source $HOME/work/secrets/terraform.work'
    alias teamsx='killall -15 teams'
    alias adm='sudo mount /home/$HOME/work/adm'
    alias mongo='ssh -L \*:27777:appserver:27017 jumphost'
    
    
    • macallik@kbin.socialOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Good to see someone else using trash & bat. Kudos for the clean alias file w/ commented headers too! I just started doing it recently and it makes edits/additions so much easier

      • conkbin@kbin.social
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        Thanks. It’s not the prettiest, but I try to keep an order of some kind… My zshrc was getting quite large, so I split it and when I did that I also put in some comments and headers.

        • macallik@kbin.socialOP
          link
          fedilink
          arrow-up
          2
          ·
          edit-2
          1 year ago

          Care to elaborate?

          For me, it once caused an issue once when I thought I was deleting files to make space for /boot/efi/ being at capacity (dual booting issues at the time) when in actuality I was just moving files to an impromptu trash can created on /boot/efi (so the lack of space remained the same lol), but on numerous occasions, it has actually saved my ass and allowed me to retrieve documents that I realized I needed to look at again.

          The only other quirk is it straight up ignores all options, so I’ve tried to delete interactively (rm -i) and then had to use trash-list to view the deleted files

          • bnjmn@lemm.ee
            link
            fedilink
            arrow-up
            1
            ·
            edit-2
            1 year ago

            Maybe I’m being a little paranoid, but I DID accidentally delete a few directories with dotenvs in them, which is what led me to find trash in the first place. That experience really traumatized me… so to break the rm habit and make sure I don’t do that on ANY computer I set up abbr rm '# Don\'t use this! Use trash-cli instead' # and abbr t trash.

            • conkbin@kbin.social
              link
              fedilink
              arrow-up
              2
              ·
              1 year ago

              I try to keep backups of almost everything, so even if I accidentally delete something and only notice after a clear the trash, there is still a chance I will recover the missing pieces.

  • ExLisper@linux.community
    link
    fedilink
    English
    arrow-up
    12
    ·
    1 year ago

    So I’ve checked and…

    alias la='ls -a'
    alias mplayer='mplayer -noautosub -alang en'
    alias ll='ls $LS_OPTIONS -lh'
    alias l='ls $LS_OPTIONS -lAa'
    alias x='startx'
    alias ekgi='ekg -i'
    alias glinks='links2 -g'
    

    My god, this must be in my .bashrc since forever. I mean… links2? ekg? startx? It’s like archeology.

    I will keep it there for future historians.

  • iHUNTcriminals@lemm.ee
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    1 year ago

    What… I didn’t know this was a thing.

    So I could make be “sudo gimme-dat-new-new” Instead of “sudo DNF upgrade -y”

    • s20@lemmy.ml
      link
      fedilink
      arrow-up
      8
      ·
      edit-2
      1 year ago

      alias gimmie-dat-new-new='sudo dnf upgrade -y'

      Although you should probably look over your upgrade before applying it as a general good practice. But, hey, I do this myself (dnfup instead of gimmie-dat-etc.), so I can’t talk too much shit.

      ETA: If you want it to be a persistent alias, though, you gotta add it to your .bashrc

    • Exec@pawb.social
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Copying multiple lines will be more difficult. You can use Ctrl+C to display the current position, use page up/down for coarse navigation.

  • learnbyexample@programming.dev
    link
    fedilink
    English
    arrow-up
    8
    arrow-down
    1
    ·
    edit-2
    1 year ago
    alias a='alias'
    
    a c='clear'
    a p='pwd'
    a e='exit'
    a q='exit'
    
    a h='history | tail -n20'
    # turn off history, use 'set -o history' to turn it on again
    a so='set +o history'
    
    a b1='cd ../'
    a b2='cd ../../'
    a b3='cd ../../../'
    a b4='cd ../../../../'
    a b5='cd ../../../../../'
    
    a ls='ls --color=auto'
    a l='ls -ltrhG'
    a la='l -A'
    a vi='gvim'
    a grep='grep --color=auto'
    
    # open and source aliases
    a oa='vi ~/.bash_aliases'
    a sa='source ~/.bash_aliases'
    
    # sort file/directory sizes in current directory in human readable format
    a s='du -sh -- * | sort -h'
    
    # save last command from history to a file
    # tip, add a comment to end of command before saving, ex: ls --color=auto # colored ls output
    a sl='fc -ln -1 | sed "s/^\s*//" >> ~/.saved_commands.txt'
    # short-cut to grep that file
    a slg='< ~/.saved_commands.txt grep'
    
    # change ascii alphabets to unicode bold characters
    a ascii2bold="perl -Mopen=locale -Mutf8 -pe 'tr/a-zA-Z/𝗮-𝘇𝗔-𝗭/'"
    
    ### functions
    # 'command help' for command name and single option - ex: ch ls -A
    # see https://github.com/learnbyexample/command_help for a better script version
    ch() { whatis $1; man $1 | sed -n "/^\s*$2/,/^$/p" ; }
    
    # add path to filename(s)
    # usage: ap file1 file2 etc
    ap() { for f in "$@"; do echo "$PWD/$f"; done; }
    
    # simple case-insensitive file search based on name
    # usage: fs name
    # remove '-type f' if you want to match directories as well
    fs() { find -type f -iname '*'"$1"'*' ; }
    
    # open files with default application, don't print output/error messages
    # useful for opening docs, pdfs, images, etc from command line
    o() { xdg-open "$@" &> /dev/null ; }
    
    # if unix2dos and dos2unix commands aren't available by default
    unix2dos() { sed -i 's/$/\r/' "$@" ; }
    dos2unix() { sed -i 's/\r$//' "$@" ; }
    
  • Pantherina@feddit.de
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    1 year ago

    I alias most of my flatpaks to autorun, made a tool for that called flatalias.

    https://github.com/trytomakeyouprivate/flatalias

    Also

    set fish_greeting
    
    alias update='flatpak update -y && notify-send -a Updater "Flatpaks ready" && rpm-ostree update && notify-send -a Updater "rpm-ostree ready"'
    
    alias upfin='flatpak update -y && rpm-ostree update && shutdown -h now''
    
    alias flatrm='flatpak remove --delete-data'
    
    alias ls="ls --color=auto -GF"
    
    alias reload="source ~/.config/fish/config.fish && echo 'Fish-config updated'"
    
    abbr conf "kate ~/.config/fish/config.fish && source ~/.config/fish/config.fish && echo 'Fish-config updated'"
    
    ### NETWORKING
    abbr myip 'curl ifconfig.co'
    abbr netlisten 'netstat -plntu'
    abbr pingtest 'ping -c 2 wikipedia.de'
    
    abbr rpmq "distrobox enter -n fedora -- dnf search"
    abbr rstat "rpm-ostree status"
    
    abbr rpmfind "rpm -qa | grep"
    
    abbr flatinst 'flatpak install -y'
    
    abbr flatfind "flatpak list | grep"
    
    abbr history-off 'set +o history'
    
    abbr sshcloud "ssh -i /home/user/.local/share/Cryptomator/mnt/SSH-keys/KEYNAME -p PORTNUMBER root@IP
    # and others
    
    abbr httpcode "curl --head --silent --output /dev/null --write-out '%{http_code}' "
    
    abbr "pin-this" "ostree admin pin 0"
    abbr "q" "exit"
    abbr c "clear"
    
    abbr errors-boot "journalctl -b"
    abbr errors-last-boot "journalctl -b -1"
    
    function copy
        if test -f $argv[1]
            cat $argv[1] | wl-copy
            echo "Copied to clipboard."
        else
            echo "Error: '$argv[1]' is not a file!"
        end
    end
    
    abbr off "shutdown -h now"
    
    function findmod
        set mod_path (whereis $argv[1] | cut -d' ' -f2)
        kate $mod_path;
    end
    
    function mdtopdf -a filename
      set -x name (basename $filename .md)
      pandoc $filename -o $name.pdf | tee $name.pdf
    end
    
    function mdtoodt -a filename
      set -x name (basename $filename .md)
      pandoc $filename -o $name.odt | tee $name.odt
    end
    
    function mdtotex -a filename
      set -x name (basename $filename .md)
      pandoc $filename -s -o $name.tex | tee $name.tex
    end
    
    abbr rootfish "sudo -i fish"
    
    abbr eng "export LANG=en_US.UTF-8"
    abbr english "export LANG=en_US.UTF-8"
    alias conf='nano ~/.config/fish/config.fish'
    alias reload='. ~/.config/fish/config.fish'
    
    alias pipwire-restart="systemctl --user restart pipewire.service"
    
    function tarbrot #not yet fully working I think
        if test -z $argv[1]
            echo "Usage: tarbrot "
            return 1
        end
    
        set folder $argv[1]
        set tarball (basename $folder).tar
        set brotli_file $tarball.br
    
        # Start the timer
        set start_time (date +%s)
    
        # Create a tarball without compression
        tar -cf $tarball $folder
    
        # Display the time elapsed
        set end_time (date +%s)
        set elapsed_time (math $end_time - $start_time)
    
        # Compress the tarball with Brotli
        brotli $tarball && rm -f "$tarball"
    
        echo "Folder '$folder' has been tarred and Brotli compressed as '$brotli_file'"
        echo "Time elapsed: $elapsed_time seconds"
        echo "Size of compressed file: (du -h $brotli_file | awk '{print $1}')"
    end
    

    I use fish btw, nice shell.

    • macallik@kbin.socialOP
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      I appreciate the focus on verbosity. I should probably set more of my defaults to follow the same thought process 🤔

  • macallik@kbin.socialOP
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    (Bash-Specific)

    App-Specific

    alias battery='upower -i $(upower -e | grep 'BAT') | grep -E "state|to\ full|percentage"' # Get the battery level of my laptop server when I ssh into it
    
    alias audio="yt-dlp -f 'ba' -x --audio-format mp3" # Download the audio version of a youtube video
    
    alias wttr="curl wttr.in/Chicago" # Get the weather of my city in the terminal
    
    

    Terminal Navigation

    alias ba2sy="cp ~/.bash_aliases ~/Sync/" # copy my current iteration of my aliases to my shared syncthing folder so that it's accessible across devices
    
    alias sy2ba="cp ~/Sync/.bash_aliases ~/" # replace the current iteration of my aliases w/ the synced version from my syncthing folder
    
    alias mba='micro .bash_aliases' # open my aliases file in the modernized version of 'nano'
    
    alias reload="source ~/.bashrc" # Quickly refresh my system so that the latest alias file is loaded
    
    alias l='exa --group-directories-first -hlras modified --no-user --icons' # exa is a prettier version of ls. Options toggled: Human-readable, long format, reverse output, show hidden files/folders, sort by modified, hide the 'user' column since I'm the only one that uses the computer, and show the icons to make it look fancy```
    
    

    Replaced Commands

    alias cat='batcat --theme=ansi ' # Replace generic output of cat w/ a formatted version. This is bat (batcat in Debian)
    
    alias rm='trash ' # Instead of auto-deleting files, put them in the 'trash' bin for 30 days, then delete.
    
    

    Server & Docker-related

    alias lazy='/home/macallik/.local/bin/lazydocker' # Run Docker
    
    alias pad='ssh MyPad20334' # shorthand to ssh into my server
    
    
  • craigevil@lemmy.ml
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    1 year ago

    A bit long, but here goes:

    Start gomuks Matrix Client

    alias gomuks=/home/craig/.local/bin/gomuks-linux-arm64

    walk: Terminal File Manager

    https://github.com/antonmedv/walk

    alias walk=“walk --icons”

    Weather:https://github.com/chubin/wttr.in

    alias weather=“/home/craig/.local/bin/weather.sh”

    Onelinershell https://github.com/Onelinerhub/shellhub

    alias oh=“/home/craig/.local/bin/oh.sh”

    Show open ports

    alias ports=‘sudo netstat -tulanp’

    Refresh .bashrc

    alias bashrc=“source ~/.bashrc”

    become root

    alias root=‘sudo -i’ alias su=‘sudo su’

    Fix which

    alias which=‘command -v’

    APT User Commands

    alias search=‘apt search’ alias file=‘apt-file search’ alias policy=‘apt policy’ alias show=“nala show”

    if user is not root, pass all commands via sudo

    if [ $UID -ne 0 ]; then alias update=‘sudo apt update’ alias ainstall=‘sudo apt install’ alias apurge=‘sudo apt purge -y --autoremove’ alias upgrade=‘sudo nala upgrade’ alias aremove=‘sudo apt autoremove -y’ alias clean=‘sudo nala clean’ alias reboot=‘sudo reboot’ alias shutdown=“sudo shutdown -P now” fi

    Handy-dandy aliases for journalctl and systemctl

    alias jc=‘sudo journalctl -b’ alias jca=‘sudo journalctl’ alias jcf=‘sudo journalctl -f’ alias jcr=‘sudo journalctl --list-boots’ alias sc=‘sudo systemctl’

    Making files immortal & executable

    alias im+=“sudo chattr +i” alias im-=“sudo chattr -i” alias exe=“sudo chmod +x”

    #Add safety nets

    do not delete / or prompt if deleting more than 3 files at a time

    alias rm=‘rm -I --preserve-root’

    confirmation

    alias mv=‘mv -i’ alias cp=‘cp -i’ alias ln=‘ln -i’

    Parenting changing perms on /

    alias chown=‘chown --preserve-root’ alias chmod=‘chmod --preserve-root’ alias chgrp=‘chgrp --preserve-root’

    copy the current working directory to the clipboard

    alias cpwd=‘pwd | xclip -selection clipboard’

    Clipboard

    alias cpy=“xclip -selection clipboard”

    quick directory movement

    alias …=‘cd …’ alias …=‘cd …/…’ alias …=‘cd …/…/…’

    go to the last directory you were in

    alias back=‘cd $OLDPWD’

    quickly find files and directory

    alias ff=‘find . -type f -name’ alias fd=‘find . -type d -name’

    Create Python virtual environment

    alias ve=‘python3 -m venv ./venv’ alias va=‘source ./venv/bin/activate’

    Ping Commands

    Stop after sending count ECHO_REQUEST packets

    alias ping=‘ping -c 5’ alias pg=“ping google.com -c 5”

    alias shortcuts

    alias rpi=“sudo rpi-update” alias rpi-next=“sudo BRANCH=next rpi-update” alias raspi=“sudo raspi-config” alias clr=“clear” alias clrh=“history -c -w ~/.bash_history” alias df=‘df -H’ alias du=‘du -ch’ alias mk=“mkdir -p” alias loading=“sudo dmesg > ~/dmesg.txt”

    ls Commands

    Colorize the ls output and human readable sizes

    alias ls=‘ls --color=auto --human-readable -al’

    Use a long listing format

    alias ll=‘ls -la’

    Show hidden files

    alias l.=‘ls -d .* --color=auto’

    Listing files in folder

    alias listkb=“ls -l --block-size=K” alias listmb=“ls -l --block-size=M”

    Colorize the grep command output for ease of use (good for log files)##

    alias grep=‘grep --color=auto’ alias egrep=‘egrep --color=auto’ alias fgrep=‘fgrep --color=auto’

    Colorize diff output

    alias diff=‘colordiff’

    Start calculator with math support

    alias bc=“bc -l”

    Resume wget by default

    alias wget=“wget -c”

    ps Commands

    alias ps=“ps auxf”

    Get top process eating cpu

    alias pscpu=“ps auxf | sort -nr -k 3” alias pscpu10=“ps auxf | sort -nr -k 3 | head -10”

    Get top process eating memory

    alias psmem=‘ps auxf | sort -nr -k 4’ alias psmem10=‘ps auxf | sort -nr -k 4 | head -10’

    Free and Used Ram

    alias meminfo=‘free -l’ alias free=‘free -mt’

    Run top in alternate screen

    alias top=‘tput smcup; top; tput rmcup’

      • megane-kun@lemm.ee
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        The struggle I sometimes face when I SSH into somewhere, lol! Fortunately, there’s a lot of differences that it’s easy realize that “this is a different machine”, and I just open a different terminal tab/window to look up the pure command versions if I need to.