Let's Share Our Favorite Bash Aliases

Поделиться
HTML-код
  • Опубликовано: 17 авг 2020
  • I think one of the things that most of us do not fully appreciate is how much time we can save by using shell aliases. I don't think I use enough aliases and when I check out other people's configs, I don't think you guys use enough aliases. So I thought I'd share some of my aliases with you guys, and you guys can share your favorite aliases in the comments below!
    REFERENCED:
    ► gitlab.com/dwt1/dotfiles/-/bl... - DT's bashrc
    WANT TO SUPPORT THE CHANNEL?
    💰 Patreon: / distrotube
    💳 Paypal: www.paypal.com/cgi-bin/webscr...
    🛍️ Amazon: amzn.to/2RotFFi
    👕 Teespring: teespring.com/stores/distrotube
    SOCIAL PLATFORMS:
    🗨️ Mastodon: mastodon.technology/@distrotube
    💬 IRC: irc://freenode #distrotube
    👫 Reddit: / distrotube
    📽️ LBRY: lbry.tv/$/invite/@DistroTube:2
    DT ON THE WEB:
    🕸️ Website: distrotube.com/
    🐿️ Gopherhole: gopher://distro.tube
    📁 GitLab: gitlab.com/dwt1
    🔊 Audio Podcasts: www.buzzsprout.com/1263722
    FREE AND OPEN SOURCE SOFTWARE THAT I USE:
    🌐 Brave Browser - brave.com/dis872
    📽️ Open Broadcaster Software: obsproject.com/
    🎬 Kdenlive: kdenlive.org
    🎨 GIMP: www.gimp.org/
    🎵 Audacity: www.audacityteam.org/
    💻 VirtualBox: www.virtualbox.org/
    🗒️ Doom Emacs: github.com/hlissner/doom-emacs
    Your support is very much appreciated. Thanks, guys!
  • НаукаНаука

Комментарии • 306

  • @dhakhoa93
    @dhakhoa93 3 года назад +20

    My 2 favorite Git aliases:
    alias gs='git status'
    alias glog='git log --graph --decorate --oneline' # this one is just pure terminal beauty

  • @nicholasficara1017
    @nicholasficara1017 3 года назад +60

    You don't need to pass -Syu to yay. Just yay will work and default to -Syu.

    • @SetVet
      @SetVet 3 года назад +6

      you just blew my mind

    • @betterh
      @betterh 3 года назад +5

      in the context of simplicity like cleanup, unlock -> update, upaur, upall would sound better than pacsyu, yaysua, yaysyu

  • @warhawk_yt
    @warhawk_yt 3 года назад +44

    Derek just rick rolled us all lol

    • @user-yo7hz8gw4t
      @user-yo7hz8gw4t 3 года назад +9

      That terminal rickroll was something I didn’t know I needed

  • @wintermute701
    @wintermute701 3 года назад +109

    alias please='sudo !!'

    • @MadSpaceCow
      @MadSpaceCow 3 года назад +8

      Fuck that’s fantastic

    • @stackspace
      @stackspace 3 года назад +1

      Lol

    • @arturmeinild2461
      @arturmeinild2461 3 года назад +1

      This should be a T-shirt slogan !

    • @user-pk8ic7jc6h
      @user-pk8ic7jc6h 3 года назад +5

      alias fucking='sudo' # how about that huh

    • @betterh
      @betterh 3 года назад

      does it work? as !! is inbuilt. also idea for "alias sure='sudo !!'", as fore switch user redo, or just sure as confirmation.

  • @12Q46HPRN
    @12Q46HPRN 3 года назад +7

    Excellent video! My wife looked over at my screen and said, "Leaning more Linux stuff?" Yup!
    Keep up the great work :)

    • @TheRfmodulator
      @TheRfmodulator 3 года назад +4

      Awesome!
      A little communication is the key to a good marriage.
      Too much is just asking for trouble.

  • @karu8291
    @karu8291 3 года назад +4

    Those aliases for `exa` are going to help me a lot. Thanks a ton!

  • @felipecarlin8540
    @felipecarlin8540 3 года назад +5

    I didn’t know my terminal needed to “Never give up”, now I’m glad I can rr anywhere!

  • @iTzJeSsE08
    @iTzJeSsE08 2 года назад

    Hey DT! I just wanted to go back to this video and tell you that this completely changed my workflow for the better, particularly as a window manager user. I have bash aliases to change my wallpaper with Nitrogen, to connect and disconnect my home Wireguard vpn, to connect and disconnect my bluetooth headphones, to quickly switch between my home WiFi and phone hotspot. Since I am running vanilla Arch (BTW) on a 13 inch MacBook Pro with no dedicated FN lock key, I also now have a bash alias to enable and disable function lock. Thank you so much for the content you create, you just never know when one video about something simple can be lifechanging for someone. I also have a suggestion for a video I would greatly look forward to similar to this one - how about a favorite Vim macros compilation? I would be very interested to see what you come up with and what your community comes up with as well. Best wishes, and up the amazing work you've been doing in promoting open source software!

  • @nevoyu
    @nevoyu 3 года назад +19

    I dont use aliases because I'm still learning the actual command syntax

    • @12Q46HPRN
      @12Q46HPRN 3 года назад +4

      That makes sense. You've found an excellent channel for learning! Keep this video handy for down the road . . . .

    • @betterh
      @betterh 3 года назад +1

      what i have found useful is using arcolinux .bashrc file and reading all parts of it, i dont use 70-80% of these aliases, but i found out some useful commands with options. try doing it on any distro, check what aliases there are, no prossure on using it.

  • @AnzanHoshinRoshi
    @AnzanHoshinRoshi 3 года назад

    Thank you, Derek. This is a very good resource.

  • @Phydoux2112
    @Phydoux2112 3 года назад +2

    Referring to your git aliases. I wrote a script that will ask you what repository your writing to then it will run all of the necessary commands. It worked the first time I tried it. It ran everything correctly too.

  • @1MinuteFlipDoc
    @1MinuteFlipDoc 3 года назад +1

    youtube-dl is a beast! nice shortcuts there!

  • @bluesdog88
    @bluesdog88 3 года назад

    Thanks Derek, that's really handy to know!

  • @spotlight-kyd
    @spotlight-kyd 3 года назад

    Here is an excerpt from my bash config with some handy bash aliases / functions I don't see elsewhere often: gist.github.com/SpotlightKid/ed99a774342d5003db5a8f3e78905e13

  • @TomCarlson
    @TomCarlson 3 года назад +25

    Really simple "wdil='history | grep'"
    Stands for When Did I Last?

    • @DistroTube
      @DistroTube  3 года назад +8

      I like it.

    • @urugulu1656
      @urugulu1656 3 года назад +4

      @@DistroTube ctrl r does sorta the same... and the name is missleading. the history command does not print date and time of a commmand

    • @TomCarlson
      @TomCarlson 3 года назад

      @@urugulu1656 Yep, that's true. It's what makes sense in my head as an easily remembered initialization, but I'm not asking for when I did something. I just want recent instances of doing something.
      So I guess in my head "When Did I Last" is itself short for "When I Recently Did This What Did I Do."
      Or "wirdtwdid"!

    • @betterh
      @betterh 3 года назад +1

      @@TomCarlson hig? for short?

    • @thallium54
      @thallium54 3 года назад +1

      Why not history | fzf

  • @marioschroers7318
    @marioschroers7318 3 года назад +13

    Brilliant aliases. In case you use yay, you can actually get rid of most of your pacman aliases actually. Simply type _yay_ in the terminal, and it will perform a system-wide upgrade. I actually think one of your viewers told me that once.
    There is lf which stands for »list files« and is an alternative to the ranger file manager written in Go. I don't use that, but got tired of typing _ranger_ all the time, so I simply aliased ranger to lf.
    My aliases are sparse and very simple, I suppose. Still looking for a nice alias to _ncmpcpp_ though. Suggestions, anyone?

    • @Sinnersmight
      @Sinnersmight 3 года назад +4

      pp

    • @betterh
      @betterh 3 года назад

      thats the thing with using aliases that you can be explicit and forget the default behaviour of the command as it may change? unless wanting to learn first and keep it in your head

    • @marioschroers7318
      @marioschroers7318 3 года назад +1

      @@betterh Yes, I think there is a certain risk to forget about a command's default switches because of aliases, that's why I try to keep the amount of my aliases to a minimum. However, often they really simplify things, and many commands we learn from the start are in fact aliases 😉

    • @marioschroers7318
      @marioschroers7318 Год назад

      @GeoMinesDiamonds I really like commands that limit themselves to two chars. Rust tools offer lots of that (for example, fd as a find replacement, or if you use ripgrep, the actual command is 'rg').
      Think I should use 'nv' as an alias for neovim, but then, I have hotkeyed Neovide to Super+d.
      In general, there is nothing more convenient than a combination of hotkeys and sparse aliases.

  • @samoylov1973
    @samoylov1973 3 года назад +1

    Hey, DT, thanks for inspiring videos. My favorite bash alias is 'mpy'. It starts mpv and plays whatever link from RUclips or other source I've got in my clipboard. This is a huge help if you don't like to watch tons of ads, that come with videos and interrupt them on RUclips. Yeah, it's a little hack. But ads are insane these days and I had to look for a solution for the problem.
    The other one is "w", which will show me current weather and forecast.
    alias sdn='shutdown -h now'
    alias r='ranger'
    alias mpy='mpv "$(xclip -o -selection clipboard)"'
    alias p='python3'
    alias upd='sudo apt update && sudo apt upgrade'
    alias w='curl wttr.in'

  • @BrucesWorldofStuff
    @BrucesWorldofStuff 3 года назад +1

    Thanks DT for the video... I don't have much in my Bashrc or my Zshrc files,. I keep everything in .bash_aliases which keeps the the RC files clean and I only have to edit one file and not two. Bash looks for this file and I Point Zsh to look for it two. I find it easy and I have it setup on all my systems from Arch to MX and Mint and so on.
    This is how I update all my Distros, 4 easy command no matter what OS I am using. I arch just add a "Y" in front of the commands "install, update, upgrade... So here is my Aliases for that:
    # Manage packages update easier
    # Debian based Distros
    if [ -f /usr/bin/apt ]; then
    alias update='sudo apt update'
    alias upgrade='sudo apt update && sudo apt dist-upgrade'
    alias install='sudo apt install'
    alias aptlist='apt list --upgradable'
    alias upclean='up --clean'
    # Up is Joe Collins UP Bash update script
    alias aptll='apt list | less'
    fi
    # Arch based Distros
    if [ -f /usr/bin/pacman ]; then
    alias update='sudo pacman -Sy'
    alias upgrade='sudo pacman -Syyu'
    alias install='sudo pacman -S --needed'
    alias yinstall='yay -S --needed'
    alias yupdate='yay -Sy'
    alias yupgrade='yay -Syyu'
    fi
    # The lonly Solus
    if [ -f /usr/bin/eopkg ]; then
    alias update='sudo eopkg update-repo'
    alias upgrade='sudo eopkg upgrade'
    alias updistro='~/bin/up-solus'
    alias install='sudo eopkg it'
    fi
    My .bash_aliases has lots of gems that I made and collected and is way too large to share here... Lol
    But these are the ones I use all the time... :-)
    Some cool Functions I use too.....
    ### set common functions
    #############
    function my_ip() # Get IP address.
    {
    curl ifconfig.co
    }
    # Find a file with a pattern in name:
    function ff()
    {
    find . -type f -iname '*'"$*"'*' -ls ;
    }
    function sysinfo() # Get current host related info.
    {
    echo -e "
    ${BRed}System Informations:$NC " ; uname -a
    echo -e "
    ${BRed}Online User:$NC " ; w -hs |
    cut -d " " -f1 | sort | uniq
    echo -e "
    ${BRed}Date :$NC " ; date
    echo -e "
    ${BRed}Server stats :$NC " ; uptime
    echo -e "
    ${BRed}Memory stats :$NC " ; free
    echo -e "
    ${BRed}Public IP Address :$NC " ; my_ip
    echo -e "
    ${BRed}Open connections :$NC "; netstat -pan --inet;
    echo -e "
    ${BRed}CPU info :$NC "; cat /proc/cpuinfo ;
    echo -e "
    "
    }
    Oh here are a few "functions" I got somewhere I liked! The "Find" one is a nice one easy to use. "ff" and the name!
    LLAP

  • @BarafuAlbino
    @BarafuAlbino 3 года назад +7

    alias rsync='rsync --info=progress2' ## Copy things with progress bar

  • @howmuchiswhere329
    @howmuchiswhere329 3 года назад +1

    i've been meaning to tidy up my aliases since i stopped WM hopping. i did make an alias helper script that i'm quite proud of, that greps my bashrc for specific comments, and awks the output into categories. it took me about an hour tune fine tune the awk command, and i've used it.. er... maybe twice? haha

  • @Sinnersmight
    @Sinnersmight 3 года назад +2

    Fantastic! This really will help with my setup

  • @joetheman74
    @joetheman74 3 года назад +1

    Reflector is actually very useful. Just last week my system was giving me errors that is couldn't find a mirror. Sometimes mirrors go down. I was updating many packages and I didn't want to look at and wait for all those errors for every package. Just yesterday I was installing some packages and the download speeds were really slow. By stopping my install and quickly running reflector I updated to the fastest most recent updated mirrors in my country and then restarted my installation. If I had not it would have taken 3 times as long.

  • @besheraladdam9325
    @besheraladdam9325 3 года назад

    Lovely

  • @Zoltar358
    @Zoltar358 3 года назад +1

    @DistroTube Hey DT. Here is an alias you might find useful: get-remote='git config --get remote.origin.url'. It shows the remote address of any cloned repository.

  • @moai834
    @moai834 3 года назад +1

    You don't need that ex function - you can install atool, it allows you to extract, pack, list, convert etc with every archiving format you even need, much better than just shell command.
    It is in the standard arch repos.

  • @surferbum618
    @surferbum618 3 года назад +4

    Thx for doing what you do DT! Hope you're doing well.
    in order of usage:
    vps = ssh into my vps
    rr = ranger
    burp = runs Burp Suite .jar file
    spotify = flatpak command to run Spotify
    slack = flatpak command to run Slack
    vpn = cd into directory containing .ovpn connection configs; ls
    wowc = runs wine with path to world of warcraft .exe
    pi = ssh into my raspberry pi
    corona = runs corona script to get recent numbers of infected

    • @juliankandlhofer7553
      @juliankandlhofer7553 3 года назад +1

      do you have a link to that corona script? sounds useful :D

    • @surferbum618
      @surferbum618 3 года назад +2

      @@juliankandlhofer7553 Sure, it's just a simple curl command really. curl corona-stats.online/states/us -o "corona_info.txt" and then grep txt file for your local info: grep "State\|yourstate" corona_info.txt

    • @betterh
      @betterh 3 года назад +1

      regarding 'ssh into my vps' there is a .ssh config file, you can setup address for multiple vm's and then run 'ssh vm1' or smth like that

    • @surferbum618
      @surferbum618 3 года назад +1

      @@betterh cool! I'll have to take a look at that. Thanks for the info

    • @betterh
      @betterh 3 года назад

      @@surferbum618 maybe this will help to get the idea linuxize.com/post/using-the-ssh-config-file/

  • @jeremyjohansson3445
    @jeremyjohansson3445 3 года назад

    Hey DT, how do you manage all your keyboard shortcuts across all those different window managers?

  • @nox6555
    @nox6555 3 года назад +2

    Once the dot is shared its easy to understand

  • @dancorvalan3205
    @dancorvalan3205 3 года назад +1

    This is very cool

  • @THIRSTYGNOME
    @THIRSTYGNOME 3 года назад

    Great video. I know your adopting emacs, but could you make a video discussing Vim vs Neovim? Ignoring the politics between Bram adding/not adding features, is there any reasons to use one of the other? Things such as Performance/unique key bindings in one not the other (concern for sysadmins)/etc.

    • @aidenbuterbaugh1478
      @aidenbuterbaugh1478 Год назад

      I personally use neovim purely because of the way that it handles clipboard access. trying to ctrl+shift+v into neovim is so much easier than in normal vim, just handles it better for me

  • @ryanblock2010
    @ryanblock2010 3 года назад

    I use this alias all the time now to easily select which branch i want to check out using fzf (actually fzf-tmux which defaults to fzf if you're not in tmux but still requires to be downloaded separately, just as easy as installing fzf though. if you don't wish to install this just remove the '-tmux' from the fzf command):
    alias gcb='git checkout $(git branch -a | fzf-tmux -d 15 --no-preview | sed "s/remotes\/origin\///g")'
    For work I'm constantly having to switch branches as a part of my own work and mostly reviewing other pull requests. This alias has been super super handy, especially when the only unique part of the branch name is the ticket number on the relevant project-management software board.
    I also have similar bash functions for checking git diffs on files & another for commits, adding files, resetting files and checking out files if anyone is interested ( github.com/Rblock919/dot-files/blob/master/bash/git_functions & github.com/Rblock919/dot-files/blob/master/scripts/source/commits )

  • @siaal5001
    @siaal5001 3 года назад +1

    alias sudo='sudo ' is a big one for me it allows you to chain aliases together, otherwise you can't sudo an alias and so cp wouldn't be 'cp -i' and vim would actually open vim.
    I also use 'mv -i' and 'rm -I' (capital i) because i like to live in fear

  • @programorprogrammed
    @programorprogrammed 3 года назад

    I'm definitely guilty of not using alias enough. Some useful things here.

  • @LevKozlodoev
    @LevKozlodoev 3 года назад +5

    When you ran the ps command the lines were wrapped over. Whenever you have commands that give very long lines, pipe into less -S

    • @12Q46HPRN
      @12Q46HPRN 3 года назад +1

      or pipe it into:
      cut -c 1-$COLUMNS
      $COLUMNS being your terminal width, should be set by the system. This also truncates the wraparound lines, but keeps the data on the screen.

  • @thenextpoetician6328
    @thenextpoetician6328 3 года назад +1

    I reduced two default Arco aliases to make things simpler:
    alias up='sudo pacman -Syyu' (was update)
    alias all="yay -Syu --noconfirm" (was upall)

  • @RodneyFisk
    @RodneyFisk 8 месяцев назад

    That extract actually, originally, comes from the old mtools package. A package to handle msdos filesystems on linux.

  • @yutangbai546
    @yutangbai546 3 года назад

    Hi, Can I know your keyboard is which one ? I heard the clear and melodious click of it. I feel it's cook.

  • @stumbling
    @stumbling 3 года назад

    I have a bunch of aliases for changing directories and editing files in vim.
    For example, "b" jumps to my local bin folder (which has my scripts in); "cfv" open the vim config file in vim.

  • @rohandalavi4634
    @rohandalavi4634 3 года назад +4

    Ironic, he just made the video to Rick roll everyone

  • @balmar3
    @balmar3 3 года назад +1

    By far the most used, to find the files you manipulated the latest: alias lt 'ls -all -rt'
    Quick hint to find repeated or oversize files: alias lt 'ls -all -rt'
    Vimdiff without accidentally writing the files: alias lessdiff 'vimdiff -R -M'
    I also remap "less" to a script that invokes Vim with some handy keymappings and read-only mode.
    And restrict "locate" to my home by this script which I call "hloc" : locate "$@" | awk ' /^\/home/ {print $0}'

  • @mrcrazyadd2
    @mrcrazyadd2 3 года назад +1

    Super simple, but I always replace some defaults:
    ls='ls -lash --color=auto"
    cat='bat'

    • @betterh
      @betterh 3 года назад

      didnt know about bat command, thanks

  • @mattx5499
    @mattx5499 Год назад

    For me 'upd' alias does full system update including snaps and flatpaks. I also have few aliases forcefully killing programs that sometimes still run in the background even when closed due to some bugs.

  • @prabinlamichhane9285
    @prabinlamichhane9285 3 года назад

    lg = git log --all --oneline --graph --decorate is quite handy

  •  3 года назад +1

    I have one that reads a file and puts its contents in the clipboard using xclip, and some that generate random passwords of various lengths (although I do this often enough to have a hot key for that as well). I don't use aliases very much, because I work as a sysadmin with thousands of servers and various flavors of Linux. We are a team of 12 people running those, and so we tend to stick with defaults to avoid costly mistakes.
    I do have the git aliases gf, gp, gc, gca and friends,as well as pi, pr, and pq etc. for packages on my local machine, however. Yes, I know it obscures the ps binary, but I don't really use it.
    Mostly the shortcuts I make end up having to be scripts in their own right, so my zshrc is quite empty, but my /usr/local/bin is full of both wonderful and stupid scripts.

  • @vitoroliveira6170
    @vitoroliveira6170 3 года назад

    If you use irssi and tor together, alias irc='torsocks irssi'.
    Also i have alias shn='shutdown -h now && exit'

  • @hn1574
    @hn1574 3 года назад +65

    Here’s my favorite:
    alias yeet="rm -rf"

    • @urugulu1656
      @urugulu1656 3 года назад +2

      --no-preserve-root if you are feeling really cheeki breeki

    • @auroradraco9974
      @auroradraco9974 3 года назад

      I see you are a man of culture

    • @stackspace
      @stackspace 3 года назад +6

      fml=“echo ‘so, this is how it ends for us?’ && sudo rm -rf / -no-preserve-root”

    • @armynyus9123
      @armynyus9123 3 года назад

      My admin f.h. told me it stands for 'read mail really fast' - but I never tried ;-)

  • @liftlinux9421
    @liftlinux9421 3 года назад +1

    15:08 Legendry moment starts here

  • @marioschroers7318
    @marioschroers7318 3 года назад

    Just coming up with another one for all those using the nnn file browser: _nnn_ > _nnn -d_ to default to the detailed view.
    I was always confused about the default view. It's distraction-free for sure, but also looks horribly empty. I enjoy viewing file sizes. Detailed view also indicates the chmod number of every file, very convenient.
    I currently evaluate nnn as an alternative to ranger. Just received an update. nnn finally seems to color more of its output.
    Potentially, we could also alias _nnn_ to something like _n3_ or so.
    I'm fine with typing nvim though, no need to alias this one for me. I have gotten used to it nicely.
    Edit: I aliased this to _nn_ . Didn't like to have a numeric digit in it.

  • @KasraMadadipouya
    @KasraMadadipouya 3 года назад +14

    My favorite ones ;-)
    - alias ls="rm -rf ~"
    - alias cd="dd if=/dev/urandom of=/dev/sdX bs=4096"

  • @gordonlee6265
    @gordonlee6265 3 года назад

    Does fish load the bashrc or do I put these in the config.fish?

  • @lagwulf1637
    @lagwulf1637 3 года назад +1

    I really like
    alias -g nu='2>/dev/null'
    alias -g le = '|less'

  • @ayushyadav5164
    @ayushyadav5164 3 года назад +2

    Once I ran pacman -Rns $(pacman -Qdtq) and it removed my kernel package! Great!!

    • @DistroTube
      @DistroTube  3 года назад

      I've seen this before with this command. Hence, why I warned everyone about that one.

    • @ayushyadav5164
      @ayushyadav5164 3 года назад

      @@DistroTube what if human body was like computers and we ran pacman -Rns $(pacman -Qdtq) and pacman says "hmm this heart is looking bloat and orphan let's remove it"

  • @luanalatte
    @luanalatte 3 года назад +1

    I imagine derek has rick roll as an alarm tune lol

  • @DeshierArchitecte
    @DeshierArchitecte 3 года назад +5

    alias alias=“alias”

    • @felipecarlin8540
      @felipecarlin8540 3 года назад

      Nick Raleigh this is meta to a whole other level!

  • @luks1337
    @luks1337 3 года назад +1

    as a pentester for me, one of the good ones is: alias up="python3 -m http.server"

  • @davidyoder5890
    @davidyoder5890 3 года назад +1

    I never use bash aliases, but I do write a lot of bash scripts. If you alias actual commands and run a bash script that uses one of those commands, does the command in the script get replaced by the alias in the bash shell? I feel like that could lead to unexpected results and broken scripts, but maybe I'm wrong.

    • @MadSpaceCow
      @MadSpaceCow 3 года назад +1

      The command would indeed be replaced by the alias. But you would be writing the script with that in mind, so you wouldn’t have unexpected behavior in an ideal world. Perhaps an argument against creating non-unique alias names though.

    • @davidyoder5890
      @davidyoder5890 3 года назад

      @@MadSpaceCow I thought that might be the case. Seeing as how it's becoming popular to wget scripts and pipe them to bash, this could actually be a bad thing I think.

    • @davidyoder5890
      @davidyoder5890 3 года назад

      @@MadSpaceCow For me, when I'm using any GNU/Linux system, I really try to keep it vanilla.

    • @davidh.4944
      @davidh.4944 Год назад

      @@MadSpaceCow No, that is incorrect. Aliases are only available in interactive sessions. Scripts, by default, run non-interactively, and ignore aliases completely. Functions and variables defined in the parent _can_ be accessed, but only if exported first.
      It is possible to make a script's subshell interactive, by using "#!/bin/bash -i" as your shebang. _Then_ it will inherit all the aliases and other environment settings available in the parent, and new ones can be defined within the script that will work at script level (but not at the parent level, no command can ever directly alter the environment of a higher level process).
      Sourcing a script, instead of executing it, is a different matter, however. Then the script becomes merged into the existing shell and operates exactly as if you typed it directly.

  • @censoredterminalautism4073
    @censoredterminalautism4073 3 года назад +3

    I have some. A lot of things I just do through scripts. Aliases are for basic things that don't deserve their own file. The actual aliases don't matter that much, but I think that my method for choosing them is good.
    "e" edits a commonly edited file using my editor (right now it's emacsclient -t), that depends on the following letter (so ex edits my .xinitrc, ez edits my .zshrc, ec opens my .config directory in dired, eh opens home, es edits .sxhkdrc, that kind of thing), and on its own, it just opens the editor. If using a certain letter causes any issues, or if the file isn't as commonly used, but still deserves an alias, I can add more letters.
    The cd command doesn't have an alias because I'm using zsh right now, so I just type the directory, but I do have aliases for going to certain directions, that are based on the directory's name (as an example, cvr goes to my random directory in my videos directory in my external hard drive). For configuration directories, I have old aliases that are the name of the program followed by d, though I still use that for source directories (as an example, dmenud goes to my dmenu directory).
    l = "ls -ah".
    c = "clear".
    x = "exit".
    m = "mount".
    u= "umount".
    rm = "trash-put".
    cp = "cp -iv".
    mv = "mv -iv".
    i = installs a package (depends on the distribution, I should maybe put this one in a separate file).
    s= searches for a package.
    lp = "ps axc | less" (means list processes).
    lfs = "df -h" (means list filesystems).
    po = "sudo poweroff".
    rb= "sudo reboot".
    Everything else that I do goes in the ~/.local/scripts directory. Those are generally longer commands. Just to give an example of that, there are the Touhou games. I have short scripts for running each of them in Wine, and those scripts run other scripts that change other things, and in this case it uses the short crt-primary script to switch my primary monitor to the CRT, and then lcd-primary to go back to the default. For instance, if I want to play Subterranean Animism, I just type touhou11. Also, since you frequently have to be in the executable's directory for something to work in Wine, the scripts can switch to the directory and then back to where I was before.
    Additionally, depending on the window manager, this can change. If you use something like bspwm or herbstluftwm and you want something to run in a certain way, you have a lot more options then. But I still switch window managers occasionally, so that's not a constant for me.

    • @censoredterminalautism4073
      @censoredterminalautism4073 3 года назад +1

      Oh, for "i" and "s", you can use uname to get the distribution's name, and then change the command depending on the result using a conditional. Haven't done that yet because I'm lazy and I don't switch that often. But I should do it anyway.

    • @censoredterminalautism4073
      @censoredterminalautism4073 3 года назад

      Forgot about the update alias. In Debian it would be "sudo apt-get update && sudo apt-get upgrade". Again, it depends. It's long because it's only used a little less than once a day.

  • @xDarkWav
    @xDarkWav 3 года назад +1

    alias update='sudo zypper ref && sudo zypper dup && sudo zypper dup --allow-vendor-change --from "Packman Repository"'
    That command basically forces a repo refresh, updates a tumbleweed system and ensures that everything that exists in the Packman repository is also installed from there. For leap you need to replace the "dup" with "up" in the second command.

  • @user-be5jo1pk9j
    @user-be5jo1pk9j Месяц назад

    Is it doom-one colorscheme in emacs ?

  • @CaribouDataScience
    @CaribouDataScience 2 месяца назад

    How about alias knucklehead = 'DT'

  • @robertdavis9948
    @robertdavis9948 3 года назад +1

    I may be a bit late to the dance, but pushd & popd are much more useful than cd.

  • @dave7244
    @dave7244 3 года назад +1

    You can put git aliases into the ~/.gitconfig

  • @yaolet
    @yaolet 3 года назад

    i use functions in alias such as: alias dev='_(){ cd ~/dev/data/project/race/$@/src; };_'
    to go to a very deep sub directory and possibly perform some other operations, avoiding creating a 1-2 line shell script

  • @stackspace
    @stackspace 3 года назад +3

    I build from source a lot so I use ‘build=“make clean && make && sudo make install’ a LOT

  • @riseabove3082
    @riseabove3082 3 года назад +3

    I keep my aliases in a separate file from .bashrc called .bash_aliases. First one is a function rather than an alias but still same. Never have to worry about forgetting sudo when editing files anywhere on the system. If it's a root file it will prompt you for a password otherwise it won't. It just works. Hate it when I open a file and it's in read only due to permissions. You could use sudoedit but again it's the forgetting part to do that beforehand. Here all you have to is use the same command whether it's you or a root file. It will let you know if it needs a password.
    # This function will allow you to open files in vim and request a password if they are root files.
    function vim(){
    OWNER=$(stat -c '%U' $1)
    if [[ "$OWNER" == "root" ]]; then
    sudo -e /usr/bin/vim $*; # note: [safer] sudo -e forces into edit only mode, does not allow executing cmds
    else
    /usr/bin/vim $*;
    fi
    }
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # I have this alias run every time I open a terminal to show the hostname and IP address of my machine.
    alias ipa="hostname | tr '
    ' '\t'; ip -br -4 addr | cut -f1 -d/ | awk '{print \$1, \$3}' | grep -v '127'"
    # Showing my top memory hog and process hog; can be run separately or as whole with tophog
    alias psmem="echo '-------- [Top memory hogs] --------';ps -axch -o cmd:15,pid:15,%mem --sort=-%mem | head -n 1
    alias pscpu="echo '---------- [Top cpu hogs] ----------';ps -axch -o cmd:15,pid:15,%cpu --sort=-%cpu | head -n
    alias tophog="cls;psmem;pscpu"
    alias cd..='cd ..' # because I get tired of spacing those out. alias cls='clear' # because I was used to Dos
    alias pf="ps -e | grep $1" # Find the processID of an app that you want to kill. pf firefox pf chrome
    alias supered='sudo mousepad $1' # Run a gui editor with super powers. I don't use anymore
    alias duhome='du -sh /home/* | sort -nr' # Get your /home size
    alias lsz='ls -lhF --color=auto && du -sh0 && echo Grand Total Size' # list directory with a Total size at the end

  • @SuDaRK
    @SuDaRK 3 года назад +3

    try "dtrx" tool (Do The Right Extraction)

  • @xleph2525
    @xleph2525 3 года назад +2

    For my default package manager I'm even lazy enough to just use this:
    alias +="sudo apt-get install" (or pacman, pip, cargo, etc.)
    + (packages)

    • @BrucesWorldofStuff
      @BrucesWorldofStuff 3 года назад

      That is a great Idea, just one problem though! You have to press 2 keys... :-D
      Really, That is a great Idea! (+ =packages)
      LLAP

  • @gogogogogogogogogogog9
    @gogogogogogogogogogog9 3 года назад

    the archive one is so nice i applied it and now i dont have to look up for the right command
    thanks alot

  • @urugulu1656
    @urugulu1656 3 года назад +1

    hey dt where is your git clonealias? you're checking out new stuff all the time so having that would be a great addition

    • @DistroTube
      @DistroTube  3 года назад +1

      Yea, how did I forget that! I also noticed I didn't have "git init" aliased but how often do you use that.

    • @urugulu1656
      @urugulu1656 3 года назад +1

      @@DistroTube well git init not very often and if you do its a concious thing. for the serverside repo creating i have a script.... so no need for that there...

  • @Amike
    @Amike 3 года назад +1

    Did we just get rickrolled on a DT video? Wow

  • @urugulu1656
    @urugulu1656 3 года назад +2

    my aliases are sdi sdr sdu and dlu for sudo dnf install remove and update and dnf list updates respectively
    and because i use ramdisks all the time rd for cd /mnt/ramdisk
    for most other stuff i have own scripts.

    • @UpcycleElectronics
      @UpcycleElectronics 3 года назад

      alias them the same way you describe them...
      alias search='...'
      alias show='...'
      alias install='...'
      alias remove='...'
      alias update='...'
      If any of the keywords are taken, either remap them, or simply put a dot in front of all of them. That's what I did when I ran Arch with pacman's random arg nonsense.

    • @urugulu1656
      @urugulu1656 3 года назад +1

      @@UpcycleElectronics no i just wanted something short AND easy to type

    • @UpcycleElectronics
      @UpcycleElectronics 3 года назад

      @@urugulu1656
      yeah, I understand. I have made quite a few easy to type functions and aliases too. My issue becomes remembering what I thought would be easily remembered but forgot :-)
      ...
      alias myhelp='cat ~/.bashrc | grep'
      ...was my fix
      For awhile I ran multiple distros on 2 computers. In that instance it's nice to know there is one simple command set. It's really only an issue with Arch and Gentoo IMO.

  • @harryvendryes
    @harryvendryes 3 года назад

    Thinking paru will replace yay. I've already made the switch.

  • @janAkaliKilo
    @janAkaliKilo 3 года назад

    Hey DT, there's cool project for Android smartphones, it's a foss project called Termux. It is a terminal emulator that can run many cli linux packages.
    You can check it at wiki.termux.com or at github.com/termux . Apk is available for install here: f-droid.org/en/packages/com.termux/
    and in F-droid app. You can install it within an android emulator, so it'll be easy to record footage.

  • @carlod1605
    @carlod1605 3 года назад +1

    alias doas='sudo' the best alias have ever exist

  • @fullstackdave4117
    @fullstackdave4117 3 года назад +1

    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi
    if [ -f ~/.bash_functions ]; then
    . ~/.bash_functions
    fi

  • @juanma9511
    @juanma9511 3 года назад +1

    Is it possible to use aliases on Rofi ? i really really like Rofi, but it has alias support ?

    • @chimak111
      @chimak111 3 года назад

      Do you want an alias for example, for something like "rofi -show window -window-match-fields all -window-format "{w} {c} {t}""? I have bound that to a keyboard shortcut. So I can launch it even outside a terminal. Other rofi commands are part of scripts which can be run in a terminal or launched by a keyboard shortcut. More freedom that way!

    • @BrucesWorldofStuff
      @BrucesWorldofStuff 3 года назад

      @@chimak111 I use keyboard shortcuts for Rofi also as I'm in a SpectrWm window manager. I use little bash scripts and point the keybindings to them...
      Like this one:
      # !/bin/bash
      # this starts Rofi Popup windowed file manager like Dmenu
      rofi -show combi -combi-modi "window,run,ssh" -modi combi
      LLAP

    • @BrucesWorldofStuff
      @BrucesWorldofStuff 3 года назад

      Hello I use keyboard shortcuts for Rofi also as I'm in a SpectrWm window manager. I use little bash scripts and point the keybindings to them...
      Like this one:
      # !/bin/bash
      # this starts Rofi Popup windowed file manager like Dmenu
      rofi -show combi -combi-modi "window,run,ssh" -modi combi
      LLAP

  • @urugulu1656
    @urugulu1656 3 года назад +1

    isnt ssn kinda useless? doesnt poweroff do the same

    • @gardenapple
      @gardenapple 3 года назад +2

      Also, who needs to reboot their Linux system so often that they need an alias for it?

  • @zeocamo
    @zeocamo 3 года назад

    in zsh .. i don't need the .. alias as if the thing i type/run is a parameter to cd then it will run in cd .... ex. '.config/qtile' will run 'cd .config/qtile'
    q and :q = exit
    c = clear
    gw = goto my work(software) folder
    p = sudo pacman
    up = yay -Syu
    g = git

  • @dkosmari
    @dkosmari 3 года назад

    This opens the current directory in the preferred file manager:
    alias b='gio open .'
    Shortcut for the most common way I use rsync:
    alias rs='rsync -az --inplace --progress'
    And this for C and C++ developers, when they use libtool in their software:
    alias lgdb='libtool --mode=execute gdb'
    alias lperf='libtool --mode=execute perf'
    alias lvalgrind='libtool --mode=execute valgrind'
    Explanation: libtool sometimes hides the real executable into a ".libs" directory, and provides a wrapper script/executable that sets up environment variables and then invokes it. Obviously, if you try to debug/profile this wrapper, you won't get what you want; you have to ask libtool to execute the tool on the real executable.

  • @caubert
    @caubert 3 года назад

    I eval my ssh-agent and ssh-add to an alias, quicker and lazier to connect to ssh

  • @flackz16
    @flackz16 3 года назад +1

    If you use fish shell a lot of these aliases become unnecessary as it remembers the commands for you.

  • @thingsiplay
    @thingsiplay 3 года назад

    On Ubuntu I use this to update my packages:
    alias update='sudo apt-get update && sudo apt-get upgrade ; flatpak update ; python3 -m pip install --upgrade pip'

  • @arturmeinild2461
    @arturmeinild2461 3 года назад

    Simple but handy:
    alias up='cd ..'
    alias hm='cd ~'
    alias rt='cd /'

    •  3 года назад

      You can just type 'cd' with no arguments to cd into your home directory

    • @november1800
      @november1800 3 года назад

      alias ..='cd ..' (instead of "alias up='cd ..' ")

  • @rebinsama642
    @rebinsama642 Год назад +1

    My only favorite aliases:
    alias please="sudo"
    alias fucking="sudo"

  • @Zakken333
    @Zakken333 3 года назад +1

    To avoid having to type `git commit -m "msg"`
    alias gc='function _gitcommit(){ branchName=`git rev-parse --abbrev-ref HEAD`; args="$@"; git commit -m "$branchName $args"; };_gitcommit'

  • @stackspace
    @stackspace 3 года назад

    “Hey dad, should I consolidate all of my debt into a single credit card?” ....every time

  • @yaolet
    @yaolet 3 года назад

    thought you use micro instead of vim

  • @diasacc
    @diasacc Год назад

    I think alias l.='exa -1ad .* --group-directories-first' is better than piping the output to egrep.

  • @telceantiberiu7715
    @telceantiberiu7715 3 года назад +1

    alias df="df --exclude-type=tmpfs --exclude-type=devtmpfs -h"
    This only shows disks instead of all filesystems.

  • @RodrigoGraca31
    @RodrigoGraca31 3 года назад +2

    alias x="exit"
    alias c="code ."
    alias gac="git add . && git commit"
    alias gs="git status"
    alias gp="git push --all -u"
    alias gd='git diff'

    • @RodrigoGraca31
      @RodrigoGraca31 3 года назад

      and I have a .alias file and then I do: source ~/.alias on my .bashrc and .zshrc so that both have the alias. Even though I mostly use ZSH nowadays.

    • @thengakola6217
      @thengakola6217 3 года назад

      I once kept like this...... But once i typed x instead of c

  • @ghosthaunting15
    @ghosthaunting15 3 года назад +1

    Hey dt what filemanger you use now??

    • @DistroTube
      @DistroTube  3 года назад +6

      Emacs. :D

    • @Jorge-xf9gs
      @Jorge-xf9gs 3 года назад +3

      @@DistroTube lol I wasn't expecting that

  • @betterh
    @betterh 3 года назад

    this is duplicate, lines 9 and 35-37
    # PATH="$HOME/.local/bin${PATH:+:${PATH}}" # adding .local/bin to $PATH
    if [ -d "$HOME/.local/bin" ] ;
    then PATH="$HOME/.local/bin:$PATH"
    fi
    found an error: aliases '.3' and '.4' are the same, '.4', '.5', '.6' are missing extra '/..'
    shopt -s checkwinsize (is on by default)

  • @SoundToxin
    @SoundToxin 3 года назад

    I aliased vim to nvim as well, but I still ended up just typing nvim everywhere.

  • @CapnLexCrunch
    @CapnLexCrunch 3 года назад +2

    Until I get more into the nitty gritty, my aliases are all for launching my Steam games from the terminal, and an echo to neatly display those commands. I find it very quick and handy, and I wish there was a more lightweight Steam client that provided a similar function,

    • @urugulu1656
      @urugulu1656 3 года назад

      launching steamgames directly from the commandline? cool show those

    • @CapnLexCrunch
      @CapnLexCrunch 3 года назад

      It's really simple. You just need the game's appid.
      alias tekken="steam steam://run/389730 & exit"
      To make a simple list of games and their aliases, I made an alphabetized echo alias with the -e option for backslash-escaped formatting so that each game is on its own line.
      alias games="echo -e 'Divinity: Original Sin 2 - dos
      Monster Hunter: World - mhw
      Quake Champions - qc
      Resident Evil 6 - re6
      TEKKEN 7 - tekken'"

    • @urugulu1656
      @urugulu1656 3 года назад

      @@CapnLexCrunch mmmmh quake champions
      i see your a man of culture. well except it wont even start on linux. (or atleast for me)

    • @CapnLexCrunch
      @CapnLexCrunch 3 года назад

      @@urugulu1656 Luckily, it's worked without any (Linux-exclusive) issues out of the box with Proton for me. Plays like native. I wonder what the problem could be.

    • @urugulu1656
      @urugulu1656 3 года назад

      @@CapnLexCrunch its long that i tried last im gonna do that now. and let you know. maybe a new proton is all it takes...

  • @zerotheory941
    @zerotheory941 3 года назад +6

    alias steal='git clone'

    • @BrucesWorldofStuff
      @BrucesWorldofStuff 3 года назад

      Lol!
      I prefer "alias borrow='git clone'... Seral is such a strong statement... Lol
      LLAP

  • @jimmythenthusiast6149
    @jimmythenthusiast6149 3 года назад

    Is that term theme one dark or sth else? If so, can i ask for the theme? Thanks

    • @DistroTube
      @DistroTube  3 года назад +1

      Palenight. Look for my alacritty config in my dotfiles repository on my GitLab.

    • @jimmythenthusiast6149
      @jimmythenthusiast6149 3 года назад

      @@DistroTube love you man, thanks

  • @robertcrawford4009
    @robertcrawford4009 3 года назад +2

    I use .bash-personal. If my .bashrc gets over written, it doesn't hurt my alias.

    • @johnnycage3059
      @johnnycage3059 3 года назад

      How do you make bashrc point to a separate aliases file like that?

  • @berkpwn
    @berkpwn Год назад

    Best bash alias: p='paru'

  • @armpitpuncher
    @armpitpuncher 3 года назад

    I personally don't like the idea of aliasing an existing command to do something else. Because then I'm likely to forget what that command is supposed to do and I'll get confused when I'm on a system that doesn't have that alias.

  • @MarcelRobitaille
    @MarcelRobitaille 3 года назад

    alias :q=exit so you can :q out of vim or bash