Let's Share Our Favorite Bash Aliases

Поділитися
Вставка
  • Опубліковано 2 гру 2024

КОМЕНТАРІ • 303

  • @dhakhoa93
    @dhakhoa93 4 роки тому +21

    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 4 роки тому +59

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

    • @SetVet
      @SetVet 4 роки тому +6

      you just blew my mind

    • @betterh
      @betterh 4 роки тому +5

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

  • @warhawk_yt
    @warhawk_yt 4 роки тому +45

    Derek just rick rolled us all lol

    • @木原篤郎-b4m
      @木原篤郎-b4m 4 роки тому +9

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

  • @Not-THAT-ChrisPratt
    @Not-THAT-ChrisPratt 4 роки тому +7

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

    • @TheRfmodulator
      @TheRfmodulator 4 роки тому +4

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

  • @wintermute701
    @wintermute701 4 роки тому +118

    alias please='sudo !!'

    • @MadSpaceCow
      @MadSpaceCow 4 роки тому +9

      Fuck that’s fantastic

    • @stackspace
      @stackspace 4 роки тому +1

      Lol

    • @arturmeinild2461
      @arturmeinild2461 4 роки тому +1

      This should be a T-shirt slogan !

    • @1337-b3c
      @1337-b3c 4 роки тому +7

      alias fucking='sudo' # how about that huh

    • @betterh
      @betterh 4 роки тому

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

  • @felipecarlin8540
    @felipecarlin8540 4 роки тому +5

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

  • @karu8291
    @karu8291 4 роки тому +4

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

  • @marioschroers7318
    @marioschroers7318 4 роки тому +12

    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 4 роки тому +4

      pp

    • @betterh
      @betterh 4 роки тому

      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 4 роки тому +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 2 роки тому

      @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.

  • @iTzJeSsE08
    @iTzJeSsE08 2 роки тому +1

    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!

  • @Phydoux2112
    @Phydoux2112 4 роки тому +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.

  • @TomCarlson
    @TomCarlson 4 роки тому +24

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

    • @DistroTube
      @DistroTube  4 роки тому +8

      I like it.

    • @urugulu1656
      @urugulu1656 4 роки тому +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 4 роки тому

      @@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 4 роки тому +1

      @@TomCarlson hig? for short?

    • @thallium54
      @thallium54 4 роки тому +1

      Why not history | fzf

  • @BarafuAlbino
    @BarafuAlbino 4 роки тому +7

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

  • @hn1574
    @hn1574 4 роки тому +65

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

    • @urugulu1656
      @urugulu1656 4 роки тому +2

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

    • @auroradraco9974
      @auroradraco9974 4 роки тому

      I see you are a man of culture

    • @stackspace
      @stackspace 4 роки тому +7

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

    • @armynyus9123
      @armynyus9123 4 роки тому

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

  • @1MinuteFlipDoc
    @1MinuteFlipDoc 4 роки тому +1

    youtube-dl is a beast! nice shortcuts there!

  • @moai834
    @moai834 4 роки тому +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.

  • @nox6555
    @nox6555 4 роки тому +2

    Once the dot is shared its easy to understand

  • @nevoyu
    @nevoyu 4 роки тому +19

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

    • @Not-THAT-ChrisPratt
      @Not-THAT-ChrisPratt 4 роки тому +4

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

    • @betterh
      @betterh 4 роки тому +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.

  • @surferbum618
    @surferbum618 4 роки тому +5

    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 4 роки тому +1

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

    • @surferbum618
      @surferbum618 4 роки тому +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 4 роки тому +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 4 роки тому +1

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

    • @betterh
      @betterh 4 роки тому

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

  • @KasraMadadipouya
    @KasraMadadipouya 4 роки тому +17

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

  • @Zoltar358
    @Zoltar358 4 роки тому +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.

  • @howmuchiswhere329
    @howmuchiswhere329 4 роки тому +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

  • @joetheman74
    @joetheman74 4 роки тому +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.

  • @liftlinux9421
    @liftlinux9421 3 роки тому +1

    15:08 Legendry moment starts here

  • @samoylov1973
    @samoylov1973 4 роки тому +1

    Hey, DT, thanks for inspiring videos. My favorite bash alias is 'mpy'. It starts mpv and plays whatever link from UA-cam 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 UA-cam. 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'

  • @siaal5001
    @siaal5001 4 роки тому +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

  • @xDarkWav
    @xDarkWav 4 роки тому +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.

  • @LevKozlodoev
    @LevKozlodoev 4 роки тому +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

    • @Not-THAT-ChrisPratt
      @Not-THAT-ChrisPratt 4 роки тому +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.

  • @BrucesWorldofStuff
    @BrucesWorldofStuff 4 роки тому +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

  • @rebinsama642
    @rebinsama642 2 роки тому +1

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

  • @programorprogrammed
    @programorprogrammed 4 роки тому

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

  • @rohandalavi4634
    @rohandalavi4634 4 роки тому +4

    Ironic, he just made the video to Rick roll everyone

  • @balmar3
    @balmar3 4 роки тому +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}'

  • @thenextpoetician6328
    @thenextpoetician6328 4 роки тому +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 Рік тому

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

  • @ryanblock2010
    @ryanblock2010 4 роки тому

    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 )

  • @fullstackdave4117
    @fullstackdave4117 4 роки тому +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

  • @AnzanHoshinRoshi
    @AnzanHoshinRoshi 4 роки тому

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

  • @luks1337
    @luks1337 3 роки тому +1

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

  • @mrcrazyadd2
    @mrcrazyadd2 4 роки тому +1

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

    • @betterh
      @betterh 4 роки тому

      didnt know about bat command, thanks

  • @censoredterminalautism4073
    @censoredterminalautism4073 4 роки тому +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 4 роки тому +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 4 роки тому

      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.

  • @lagwulf1637
    @lagwulf1637 4 роки тому +1

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

  • @riseabove3082
    @riseabove3082 4 роки тому +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

  • @stackspace
    @stackspace 4 роки тому +3

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

  • @DeshierArchitecte
    @DeshierArchitecte 4 роки тому +6

    alias alias=“alias”

    • @felipecarlin8540
      @felipecarlin8540 4 роки тому

      Nick Raleigh this is meta to a whole other level!

  • @bluesdog88
    @bluesdog88 4 роки тому

    Thanks Derek, that's really handy to know!

  • @thingsiplay
    @thingsiplay 3 роки тому +1

    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'

  • @davidyoder5890
    @davidyoder5890 4 роки тому +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 4 роки тому +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 4 роки тому

      @@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 4 роки тому

      @@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.

  • @flackz16
    @flackz16 4 роки тому +1

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

  • @dave7244
    @dave7244 4 роки тому +2

    You can put git aliases into the ~/.gitconfig

  • @jeremyjohansson3445
    @jeremyjohansson3445 4 роки тому

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

  • @xleph2525
    @xleph2525 4 роки тому +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 4 роки тому

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

  • @marioschroers7318
    @marioschroers7318 4 роки тому

    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.

  • @mattx5499
    @mattx5499 2 роки тому

    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.

  • @carlod1605
    @carlod1605 4 роки тому +1

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

  • @dkosmari
    @dkosmari 4 роки тому

    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.

  • @robertdavis9948
    @robertdavis9948 4 роки тому +1

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

  • @yutangbai546
    @yutangbai546 4 роки тому

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

  • @Amike
    @Amike 4 роки тому +1

    Did we just get rickrolled on a DT video? Wow

  •  4 роки тому +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.

  • @Sinnersmight
    @Sinnersmight 4 роки тому +2

    Fantastic! This really will help with my setup

  • @RodrigoGraca31
    @RodrigoGraca31 4 роки тому +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 4 роки тому

      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 4 роки тому

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

  • @luanalatte
    @luanalatte 4 роки тому +1

    I imagine derek has rick roll as an alarm tune lol

  • @vitoroliveira6170
    @vitoroliveira6170 4 роки тому

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

  • @stumbling
    @stumbling 4 роки тому

    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.

  • @gordonlee6265
    @gordonlee6265 4 роки тому

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

  • @ayushyadav5164
    @ayushyadav5164 4 роки тому +2

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

    • @DistroTube
      @DistroTube  4 роки тому

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

    • @ayushyadav5164
      @ayushyadav5164 4 роки тому

      @@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"

  • @CaribouDataScience
    @CaribouDataScience 6 місяців тому

    How about alias knucklehead = 'DT'

  • @FaridFaracli
    @FaridFaracli 6 місяців тому

    Is it doom-one colorscheme in emacs ?

  • @yaolet
    @yaolet 4 роки тому

    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

  • @urugulu1656
    @urugulu1656 4 роки тому +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 4 роки тому

      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 4 роки тому +1

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

    • @UpcycleElectronics
      @UpcycleElectronics 4 роки тому

      @@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.

  • @stackspace
    @stackspace 4 роки тому

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

  • @urugulu1656
    @urugulu1656 4 роки тому +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  4 роки тому +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 4 роки тому +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...

  • @hydronaphthoquinone
    @hydronaphthoquinone 4 роки тому +1

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

  • @Zakken333
    @Zakken333 4 роки тому +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'

  • @prabinlamichhane9285
    @prabinlamichhane9285 4 роки тому

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

  • @arturmeinild2461
    @arturmeinild2461 4 роки тому

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

    •  4 роки тому

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

    • @november1800
      @november1800 4 роки тому

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

  • @SuDaRK
    @SuDaRK 4 роки тому +3

    try "dtrx" tool (Do The Right Extraction)

  • @CapnLexCrunch
    @CapnLexCrunch 4 роки тому +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 4 роки тому

      launching steamgames directly from the commandline? cool show those

    • @CapnLexCrunch
      @CapnLexCrunch 4 роки тому

      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 4 роки тому

      @@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 4 роки тому

      @@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 4 роки тому

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

  • @THIRSTYGNOME
    @THIRSTYGNOME 4 роки тому

    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 2 роки тому

      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

  • @dancorvalan3205
    @dancorvalan3205 4 роки тому +1

    This is very cool

  • @juanma9511
    @juanma9511 4 роки тому +1

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

    • @chimak111
      @chimak111 4 роки тому

      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 4 роки тому

      @@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 4 роки тому

      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

  • @robertcrawford4009
    @robertcrawford4009 4 роки тому +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?

  • @diasacc
    @diasacc Рік тому

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

  • @besheraladdam9325
    @besheraladdam9325 3 роки тому

    Lovely

  • @betterh
    @betterh 4 роки тому

    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)

  • @urugulu1656
    @urugulu1656 4 роки тому +1

    isnt ssn kinda useless? doesnt poweroff do the same

    • @gardenapple
      @gardenapple 4 роки тому +2

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

  • @juliankandlhofer7553
    @juliankandlhofer7553 4 роки тому +7

    not an alias but a function to automatically ls after each cd:
    function cd {
    builtin cd "$@" && ls
    }

    • @w01dnick
      @w01dnick 4 роки тому +1

      Why would anyone need this as permanent behaviour?

    • @betterh
      @betterh 4 роки тому +3

      alias it as lsd lol

    • @juliankandlhofer7553
      @juliankandlhofer7553 4 роки тому +1

      @@w01dnick why? because I would ls after every cd anyway. there's rarely a time I want to switch to a directory without knowing what's in it.

    • @w01dnick
      @w01dnick 4 роки тому

      @@juliankandlhofer7553 every time? after every cd? usually I know what is in directory to which I switching…

    • @stackspace
      @stackspace 4 роки тому

      @@w01dnick can confirm. i 'ls' after every cd as well. maybe i formed it as a habit early? idk, but this alias helped me! and, actually @Julian Kandlhofer , I made it better:
      function cd() {
      if [ -z "$1" ]; then
      builtin cd ~ && ls -lah --color=auto
      else
      builtin cd "$1" && ls -lah --color=auto
      fi
      }
      This way, you don't lose the ability to 'cd' into home!
      edit: now that I see the code again, i broke the coding standard for 'if' statements -- the most common option should be first. Since is 'cd $1' a lot more than 'cd', I should reverse this.

  • @ghosthaunting15
    @ghosthaunting15 4 роки тому +1

    Hey dt what filemanger you use now??

    • @DistroTube
      @DistroTube  4 роки тому +6

      Emacs. :D

    • @Jorge-xf9gs
      @Jorge-xf9gs 4 роки тому +3

      @@DistroTube lol I wasn't expecting that

  • @duliomatos
    @duliomatos 4 роки тому +1

    A simple one for your Download folder to see the name of or edit just the last created file. e.g.
    alias lf='ls -t | head -n 1'
    alias vlf='vim `lf`'
    For many things I use all day I just create small aliases
    alias f='find . -name'
    alias v='vim'
    alias p='pwd'
    alias l='less'
    alias revert='hg revert -r .~1'
    alias sl='hg sl'
    alias s='hg st'
    alias d='hg diff'
    alias hgf='hg status --rev .^::.'
    alias hgfm='hg status --rev master::.'
    ...
    And for other things I just create a lot of functions inside my bashrc and alias them, e.g. for a dialog that changes the current mercurial bookmark. Probably should explorer 'dialog` more for other stuff
    books() {
    hg log -r "sort(bookmark(), -date)" -T "{bookmarks}
    "
    }
    bookmenu() {
    opts=""
    n=1
    declare -a options
    for b in $(books); do
    options[$n]=$b
    opts=$opts"$n $b ";
    n=$(expr $n + 1)
    done
    choice=$(dialog --clear --backtitle "Mercurial" --title "Change bookmark" --menu "Select a bookmark" 50 100 30 $opts 2>&1 >/dev/tty)
    hg checkout ${options[$choice]}
    }
    alias cb=bookmenu2

  • @jimmycoconut88
    @jimmycoconut88 4 роки тому

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

    • @DistroTube
      @DistroTube  4 роки тому +1

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

    • @jimmycoconut88
      @jimmycoconut88 4 роки тому

      @@DistroTube love you man, thanks

  • @zeocamo
    @zeocamo 4 роки тому

    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

  • @ixubux
    @ixubux Місяць тому

    alias bye="shutdown -h now"
    alias wink="reboot"

  • @ashwinrawat9622
    @ashwinrawat9622 4 роки тому +2

    Alias celar="clear "
    Alias cler="clear"
    Alias cear="clear"
    Alias clea="clear"
    Alias clr="clear"
    Alias cl="clear"

    • @DistroTube
      @DistroTube  4 роки тому +2

      Ah yes! How did I forget the "I can't type" aliases!

    • @debajit
      @debajit 4 роки тому +1

      Just press Control+L to clear the screen. That should work in all major Unix shells. Since clearing the screen is such a common operation, you should never typically need to type it in manually. You can even type in Control+L in the middle of typing in a long command

    • @thengakola6217
      @thengakola6217 4 роки тому +1

      🤣🤣🤣
      Just use c=clear

    • @ashwinrawat9622
      @ashwinrawat9622 4 роки тому

      @@debajit thanks for helpful tip

    • @ashwinrawat9622
      @ashwinrawat9622 4 роки тому

      @@thengakola6217 I'll add that to the list

  • @gogogogogogogogogogog9
    @gogogogogogogogogogog9 4 роки тому

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

  • @dolorsitametblue
    @dolorsitametblue 4 роки тому

    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.

  • @LINUXBANDIT
    @LINUXBANDIT Рік тому +1

    alias 1='sudo apt-get update && sudo apt-get full-upgrade'

  • @harryvendryes
    @harryvendryes 3 роки тому

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

  • @zerotheory941
    @zerotheory941 4 роки тому +6

    alias steal='git clone'

    • @BrucesWorldofStuff
      @BrucesWorldofStuff 4 роки тому +1

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

  • @whiskeylinux
    @whiskeylinux 4 роки тому

    alias uu="sudo apt update; sudo apt upgrade"
    alias install="sudo apt install"
    alias rmv="sudo apt remove --purge"
    alias autorm="sudo apt autoremove -y"
    alias search="sudo apt-cache search"

  • @couchcamperTM
    @couchcamperTM 4 роки тому +1

    still not using zsh? xD