Essential Keybindings For Bash, Fish and Zsh

Поделиться
HTML-код
  • Опубликовано: 16 ноя 2024

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

  • @pizzapizza1460
    @pizzapizza1460 2 года назад +19

    I was a Windows user 2 weeks ago; now an Arch user & if it wasn't for your vidz & the wiki... I'd probably still be using Windows. Merci 😌

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

      Welcome to Linux! It's a deep rabbit hole. :D

    • @pizzapizza1460
      @pizzapizza1460 2 года назад +7

      @@DistroTube ohh yeah, I have much to learn but determined 🧠 💪

    • @4cps777
      @4cps777 2 года назад +3

      Sometimes jumping in to the cold water is the easiest way to go about something. I literally began my Linux journey by installing Arch and then uninstalling Windows after previously having been contemplating about doing so for an entire year. Ig Linux is pretty easy once you get the hang of it and Arch imo has the advantage over other distros that it just works unless you do stupid things with it.

    • @pasteyourinjectionstringhere
      @pasteyourinjectionstringhere Месяц назад

      @@pizzapizza1460 How's the learning going? :)

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

    Instead of configuring vi mode in Bash you could configure for many programs at once using .inputrc, it's a configuration file for the GNU readline library which is used for text prompts in many CLI tools, not just Bash but also Python interactive shell, etc. There are a bunch of config options but the basic one is "set editing-mode vi" in .inputrc which applies it to all programs at once! (Zsh does not use .inputrc and I don't think Fish does either, but Bash definitely does)

  • @marot360
    @marot360 2 года назад +1

    I know and use some of these key bindings for many years. I still learnt new and useful ones from your short video.

    • @rafalg87
      @rafalg87 2 года назад +1

      I didn't know about alt+. and it seems super useful, can't wait to try it in practice. I wish someone compiled a list of quick wins like that. You can go for years without knowing that e.g. double click + drag selects text by full words. But I guess it would be hard to make such a list complete and avoid too much detail at the same time.

  • @ProCoder2007
    @ProCoder2007 2 года назад +1

    O-M-F-G. Thanks, just thanks! I never questioned if there were keybindings...

  • @PhyFlame
    @PhyFlame 2 года назад +4

    I've been using a lot of emacs bindings without knowing their origin. It is very nice to know such things and also be aware of options (like `set -o vi`) in order to change them. This will permanently influence how I work with the shell, thank you very much.
    Also I'm checking out the emacs video right now^^

  • @michakozio7460
    @michakozio7460 2 года назад +15

    In vi mode use '_' character in normal mode to get the last parameter of the last command. You can also use the numbers before to get the argument of the specific number.

  • @Yimyim
    @Yimyim 2 года назад +42

    CTRL-y is not really an undo. It's more like a paste command (which it is in Emacs).
    And CTRL-w, ALT-d, CTRL-k, and CTRL-u are more like cut commands.
    So you can actually move an argument or word around using these commands.
    For example, if you have
    $ echo word1 word2
    and you press "CTRL-w ALT-b CTRL-y " you will get
    $ echo word2 word1

    • @dragonsage6909
      @dragonsage6909 2 года назад +2

      Could you just use ctrl - T to swap args also!?

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

      Yes! And if you press CTRL-y multiple times it will paste what was cut several times. This "undo" stuff was really confusing until I figure that out by trying to undo multiple times.

    • @mellowgeekstudio
      @mellowgeekstudio 2 года назад +2

      @@dragonsage6909 As far as I can tell, CTRL-t will swap only the last two CHARACTERS positions. if you use it with "echo word1 word2" you get "echo word1 wor2d"

    • @dragonsage6909
      @dragonsage6909 2 года назад +1

      @@mellowgeekstudio ok, thx.. still experimenting.. there are a lot of these.. :)

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

      @@dragonsage6909 Indeed. No problem.

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

    A long time ago (though still in this galaxy), I used emacs. These days I'm a vim addict. But I tried vim keybindings for bash and ended up going back to the standard emacs ones.

  • @theodorealenas3171
    @theodorealenas3171 2 года назад +1

    The thumbnail was gorgeous!

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

    "set -o vi" was the solution to all my miseries and it's been so many years I didn't know that.

  • @dragonsage6909
    @dragonsage6909 2 года назад +4

    Great episode, I'm trying to use these more lately, great time savers.
    Ty

  • @cathalogrady2331
    @cathalogrady2331 2 года назад +4

    just a note ^ brings you to the start of text , 0 brings you to the actual start of the line regardless of leading whitespace or tabs

  • @LordHonkInc
    @LordHonkInc 2 года назад +4

    Well hot damn, I've been working in the shell for more than a decade and didn't know that I could change to vi bindings, what an oversight.
    Also, just to take advantage of shells and fish in particular being discussed: don't be surprised if you change to fish and "!!" or "!$" don't work, that's apparently by design - a design I very much disagree with and why "plugin-bang-bang" is the first thing I install alongside fish. Call me oldskool, but "sudo !!" will probably forever be more ingrained in my mind rather than "[UP]->Ctrl+A->sudo "

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

      Go to my GitLab and look in my Dotfiles repo.. Find my .config/fish/config.fish. There are two custom functions in there, one for "!!" and another for "!$". ;)

  • @RodrigoPolo
    @RodrigoPolo 2 года назад +1

    1. In macOS Terminal, in the options->Profile tab, enable the checkbox "Use Option as Meta key" to have this keybindings.
    2. I just want to thank you for this content and channel, I though I knew how to use the terminal until I saw your content, which is like a glass of water in a desert.

    • @rafalg87
      @rafalg87 2 года назад +1

      I guess the macOS terminal has some settings that make it more usable, but I eventually switched to Kitty, much better experience. I think Alacritty is also available.

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

      @@rafalg87 Thanks for the tip.

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

    Thank you for covering this. I learned that stuff in school, but I had forgotten so much of it. And, being a Windows user mainly, kindof dumbs me down. I just use arrow keys & only few extras.

  • @syrefaen
    @syrefaen 2 года назад +1

    Oh no I am used to emacs standards, very useful to know!

  • @muddyexport5639
    @muddyexport5639 2 года назад +1

    Thank you. Good info. Relearned a forgotten.

  • @stefmyt5062
    @stefmyt5062 2 года назад +8

    Fun fact, in the Fish shell you can use alt+l to run "ls".

  • @marioschroers7318
    @marioschroers7318 2 года назад +11

    Good one, as always 🙂
    Hey, DT! Recently, I find myself using a lot of regex in my nvim workflow (%s/...). Would you consider making a video on the topic?

  • @anon_y_mousse
    @anon_y_mousse 2 года назад +6

    For my keybindings, I've got home and end to go to the start and end of a line, Ctrl+{LArrow,RArrow} to navigate by words, Ctrl+Del to delete forward and Alt+Backspace to delete backwards. Though, I really don't do much line editing. I tend to just add to my .bashrc anything I keep typing repeatedly and occasionally if I need something temporarily I'll just create a function at the terminal. Sometimes I'll make a .sh file if I don't want it polluting the .bashrc but I need it multiple times, like starting up qemu instances.

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

    As always writing a comment to support the channel

  • @stefosters
    @stefosters 7 месяцев назад

    Great channel. Thanks so much for sharing all the valuable information and experience 👍👍👍

  • @thingsiplay
    @thingsiplay 2 года назад +6

    Most useful setting is to enable Vi keybinding and the different modes in the shell. And on ZSH is even a plugin with extended support for Vim like key bindings and functionality in the shell.

    • @anon_y_mousse
      @anon_y_mousse 2 года назад +1

      I've not really done a whole lot of line editing with my commands, but I tried vi keybinding just now and it's certainly neat, but how do you tab complete backwards and forwards with it, and how do go up to edit a line without moving over to hit an arrow key?

  • @brads2041
    @brads2041 2 года назад +1

    Very helpful as a newbie

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

    Apart from the attention given to vi keybindings this was a great video. Mind you that quite a lot of appliances ( Cisco, Arista, Fortigate etc. etc. ) also use these key bindings, i.e. the EMACS key bindings 😋

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

      I was going to say the same thing about the EMACS bindings!

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

    ctrl + left/right arrow will move your cursor by 1 word forward or backward. just like alt+b/f

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

    This is super helpful. Thanks DT!

  • @IainNitro
    @IainNitro 2 года назад +1

    Very Good Info in this video.

  • @AliensInc.
    @AliensInc. 2 года назад +1

    For beginning of the line and end, you can also use 'home' and 'end'.
    But this might already be setup somewhere that I don't know about

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

    Nice I usually use "$!" for the last argument retrieval in emacs mode .. "Alt ." is faster... indeed if you ever need to run commands with long arguments such as ffmpeg in the cmd line you will force yourself to learn these jump shortcuts

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

    Could you explain copying/cutting and pasting text shortcuts? And these vim *, + registers, how to use them in a convenient way??

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

    In Emacs mode ctrl-x ctrl-e opens an editor for the command line. There are times it is handy. It will use your system default editor or honor $EDITOR if set.

  • @fluca1978
    @fluca1978 2 года назад +1

    every time a vim user approaches me and tries to convince me how bad Emacs is, I ask back which shell he uses, and always it turns out it's Bash, and then I say "oh, well, you know Emacs keybindngs too!"

  •  2 года назад

    Nice video, thank you for that. Is there any key binding for scrolling?

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

      scrolling is related to the terminal emulator and has nothing to do with the shell.

  • @matthew78uk
    @matthew78uk 9 месяцев назад

    I love that T-shirt! 🤣

  • @markwilson1377
    @markwilson1377 5 месяцев назад

    That shirt is hilarious!

  • @SylvesterInk
    @SylvesterInk 2 года назад +1

    ctrl-r allows you to search for a previous command in your history.

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

    Ctrl+L works in normal mode with vi bindings. Use Ctrl+Alt+L in insert mode.

  • @13thravenpurple94
    @13thravenpurple94 2 года назад

    Great work 🥳🥳🥳 Thank you 💜💜💜

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

    ctrl + l works with zsh in vim mode btw

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

    hey DT! i recently broke my monitor by putting it on a paused bright RUclips video. it would be nice to make a video talking about the importance of screensavers, show xscreensaver and also add it to the DTOS script

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

    Curious, will this work during a command line installer for say Arch or Gentoo? I'm always having to change a misspelled package when I'm installing all of my packages during an Arch install. Can I go back word by word and fix the error(s) using these keybindings?

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

    Would be nice to configure any terminal to use vim key bindings

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

    When using the vi mode you are in the 'insert' mode at first. You must hit ESC to get out of that mode.

  • @milohoffman274
    @milohoffman274 2 года назад +2

    set -o vi, is all you need

  • @chrissaltmarsh6777
    @chrissaltmarsh6777 2 года назад +1

    Quite a lot of this works the same in tcsh. (I use that for historical reasons - csh rather than sh. I forget why,)

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

    Hey DT, completely unrelated to the video but I've always wondered, since PCManFM is your go-to GUI file manager, why don't you use it manage the desktop wallpaper in your WM sessions instead of using Nitrogen?

  • @gorillaglued
    @gorillaglued 6 месяцев назад

    7:05 Ctrl + D is not related to the emacs/vi keymap, It sends an EOF to bash, or any command running, which denotes the end of input.

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

    Very useful :) thanks

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

    Hey DT can you do a video on USBguard?

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

    Hey DT, you have a broken Audacium link in the description, apparently they've moved to other website 😃

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

    can you just manually change the keys? I would not mind getting standard copy paste working, as well as just nuking 90% of the other keys. I like arrow keys, ctrl_arrow keys for by word (I might just change that to begingin/ending of line), then I would like a clear all text key, normal copy paste. ESC could be whatever , stop I guess?

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

    Correction: Ctrl+y isn't undo. It is paste. But when you do Ctrl+u it also sets the text in the clipboard.

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

    You should try to put the keys pressed on screen.

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

    First and foremost, thank you very much for your videos!! Been a longtime Mint/Manjaro & Openbox user and your videos gave me the courage to jump toward vanilla Arch.
    Thanks to your various and in-depth info, I now have a customized AwesomeWM to my satisfaction and I am now setting the terminal to vi mode. I just finished updating my vimrc file and talk about perfect timing...
    probably nothing, but my 2 cents regarding 'clear' for clearing TERM screen....... =)
    I've been using an alias 'clr' for 30 years as my pseudo solution
    still same 3-stroke keys, visual confirmation, and works whether ur in emacs & vi mode.
    Once again, thank you very much for your hard works.
    Cheers,

  • @CyperN077
    @CyperN077 2 года назад +1

    Hey DT this is a great video because I discovered my bindings are messed up. ALT-f doesn't do anything while all the other keybindings work?
    Now I need to find the problem or else I'll be forced to use the arrow keys! SOMEBODY HELP!

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

      Many terminal emulators have their own custom keybindings as well. It's possible that your terminal has Alt-f set to something else.

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

      @@DistroTube that was my first thought but there is isn't one. For a one handed x programmer remembering all the key bindings is maddening.

  • @distant6606
    @distant6606 2 года назад +1

    thnx for the vid dt

  • @boyscout399
    @boyscout399 2 года назад +2

    When you're in vim mode does it respect your .vimrc? I have bindings like jj to go to normal mode.

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

      The shell does not use your vim (or emacs) configs because you are not actually running Vim/Emacs. You're just running the shell, and the shell has its own config file (the .bashrc for instance, in bash). I'm pretty sure you could re-bind the command to go to normal mode from ESC to jj or anything else. In bash, you'd use the 'bind' command. Type 'bind' and hit TAB and you will see all of the possibilities. I think vi-movement-mode is the one you are looking for..

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

      Thanks for that. Will try tonight

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

    I use c-w, c-u every time, anybody knows if exist a command to clear all line in any position? Like Esc in Prompt Command of Windows.
    I don't know about Vi mode, is possible custom mapping?

    • @JCRMatos
      @JCRMatos 3 месяца назад

      Create a ~/.inputrc with this content
      $include /etc/inputrc
      # Configure Esc to clear line
      # "\e": kill-whole-linevi # vi mode
      "\e": kill-whole-line # emacs (default) mode

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

    Moving or deleting by words is sometimes a little unpredictable, for instance it might be that dashes are considered a word boundary and underscores aren't.
    So, I sometimes fall back to moving/deleting by individual characters, which can be vastly improved by configuring your OS's key repeat settings. You can do that from your DE's settings UI or from the command line, for instance in Gnome you'd run:
    gsettings set org.gnome.desktop.peripherals.keyboard delay 250
    gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 25
    Bear in mind it affects everything, not just the terminal. But once you try it I don't think you'll want to go back.

  • @sociallyawkwardsimmer
    @sociallyawkwardsimmer 3 месяца назад

    I realise this is kinda necroposting, but I'm trying to learn all I can. In Kubuntu 24.04 using ZSH, CTRL+U is deleting the entire line of text, not just from the cursor back. Is this normal?
    Thanks.

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

      no thats not normal. its probably something with zsh i dont use it doe

  • @СергейЛюбимов-у3ф
    @СергейЛюбимов-у3ф 2 года назад

    For me Ctrl-u deletes whole line for some reason

  • @艾曦-e4g
    @艾曦-e4g 2 года назад

    Great! zsh-vi-mode is a zsh plugin which is very helpful. I just wonder how to set the mode of neovim after press ":", do you guys have any ideas?

  • @csehszlovakze
    @csehszlovakze 2 года назад +1

    *Latte has been discontinued!* The author shared the bad news on their website and on r/kde

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

    Это супер контент ) Ждем еще.

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

      why would you write a comment in russian on an english channel?

    • @ringnull
      @ringnull 2 года назад +1

      @@utsupp1274 In our times, when we have google translate, the language in which we write to each other is not so important. I am Russian, so I wrote a comment in my language.

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

    Ctrl+Y is not weird. "Y" stands for "yank", when you are yanking back what you just deleted.

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

    I wondered when I saw your Manjaro T-Shirt and now I wonder again.
    Where do you get these Shirts? ;)

    • @13Wirrlicht42
      @13Wirrlicht42 2 года назад +1

      There is a link in the videodescription.

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

    where did you get your shirt from

    • @13Wirrlicht42
      @13Wirrlicht42 2 года назад

      There is a link in the videodescription.

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

    Weird binding?
    You know what really weird is?
    Enter to copy.
    (anyone knows which shell is using it?)

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

    Oxford comma missing in title

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

    I would like to propose you a subject for your channel: Window Managers that run on Wayland! I know you already talked about Sway here, but I would like you to comment on others, like Wayfire, Hyprland, River, etc.That's if you can and when you can too...

  • @alexandrosvangelatos9979
    @alexandrosvangelatos9979 2 года назад +1

    Which is wierder,
    Ctrl + Y for undo or
    Ctrl + Z for undo....
    For ctrl + z,
    I think it's a little more convenient because it is close to cut (ctrl + x), copy (ctrl + c) and paste (ctrl + v)

    • @kaptkraut
      @kaptkraut 2 года назад +1

      Depends if you are on a qwertz or qwerty keyboard ;)

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

      @@kaptkraut I didn't even think about qwertz. Poor people....

  • @user-tw2kr6hg4r
    @user-tw2kr6hg4r 3 месяца назад

    vim mode in zsh is better honestly

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

    GVDT.

  • @alexandrosvangelatos9979
    @alexandrosvangelatos9979 2 года назад +1

    I've switched to vi mode for the key bindings... If you use vim as your text editor it only makes sense....
    I can never remember the emacs bindings...
    They are not intuitive at all...

    • @romany8125
      @romany8125 2 года назад +1

      I was just waiting for some vimster to show up and start pouring crap on emacs. Let the holywar begin!

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

      @@romany8125 sorry dude,
      But honestly the emacs bindings are just weird....
      I'm learning emacs but with evil mode...

  • @mko8387
    @mko8387 2 года назад +1

    not first

  • @GrigoNiko
    @GrigoNiko 2 года назад +1

    Wait, there was a vi-mode in a shell all that time?! I'm out, peace V
    :q!

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

    Its sudO not sudu.

  • @pwnwriter
    @pwnwriter 2 года назад +1

    first

  • @thefossenjoyer3346
    @thefossenjoyer3346 2 года назад +2

    First?!

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

    Eyyo pin my comment?

  • @4x5au
    @4x5au 2 года назад

    Your kernel is very outdated

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

    Fix the stupidity by adding set -o vi to the end of your .bashrc and enjoy vim keybindings.