Bash function fun, who needs ZSH when you can just do this.

Поділитися
Вставка
  • Опубліковано 27 вер 2024
  • Gitlab
    gitlab.com/jped
    Github
    github.com/jdp...
    Email Me At
    jake@jpedmedia.com
    My Website
    jpedmedia.com
    Follow Me On Odysee
    odysee.com/$/i...
    Support
    Brave users can support me with BAT on my website or on my youtube channel

КОМЕНТАРІ • 70

  • @Jeff_Seely
    @Jeff_Seely 8 місяців тому +2

    I love it brother!. You are not hindered in giving us a 'praise God', hallelujah, or an 'amen'. I'll say it too! Praise the Lord!!! Thanks for this upload. This page is becoming my favorite to visit!

    • @JakeLinux
      @JakeLinux  8 місяців тому +1

      Thank you very much, all.glory to God, I am blessed to be able to do this and enjoy every minute of it, I'm glad you enjoy the content.

  • @xwinglover
    @xwinglover 16 днів тому

    Late to the party, just what I was looking for brother. Great vdeo and demo of the bash scripting process... it's the next logical step into ricing my system and customising it to my ultimate workflow.

  • @kayzero9689
    @kayzero9689 4 місяці тому

    Really appreciate your videos, Thanks for making them.

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

    Impressing, and very interesting! I'm happy with the alt+C fzf trick, but more similar content will make me a happy child :-)
    Thank you and have a nice

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

      Thank you, I like figuring out little tricks like this.

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

    You coukd use ls to list directories only, but that's quite cool as well.

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

    Mine is a very simple ask ,can we add up in selection line --width 20% ,will it look a more table like, can we do that without errors.

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

      I attempted to add the width option in the selection line and it threw an error, apparently there is no width option, there may be a work around, I will check and see what I can find.

  • @NamasenITN
    @NamasenITN 3 місяці тому

    I wonder why you did not use the ** TAB that comes with fzf. Why it does not work optimally for you?

  • @gabriellevesque2185
    @gabriellevesque2185 2 роки тому +2

    The actual explanation of the cd() code :
    If what's in the [[ ]] is true, then it will evaluate what's on the right of the "&&", because that's an "AND" statement, if the left expression is false, there's no point executing what's on the right of "&&", because the whole line will return False anyway.
    Now, the "return" is just to Exit the function, without executing the rest of it.
    It is completely unrelated to the keyboard's return key.
    With that said, the second line :
    " builtin cd '$@' "
    will Only execute if the the first line didn't exit the whole function :)
    ( I can probably explain it better by voice, and I'm on my phone ;_;
    It's not necessarily straightforward to understand by only reading my comment haha )

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

      Thank you for breaking that down correctly. I saw that function (or at least something similar) somewhere and was trying to remember it as I typed and just guessed at what each part was doing, I make no claim to be a bash expert and have and will make many mistakes and be wrong about things, it's all part of learning. Important thing is that it worked : )

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

      @@JakeLinux Oh no worries, I am definitely no bash expert either! I only like to help when I get the chance, simply liked to explain what the code was doing 👍
      But I do work as a programmer, so I like what is related to it! 😄

  • @uuu12343
    @uuu12343 2 роки тому +3

    Finally, time to add-on to my "reasons to justify staying with Bash and not Switch to zsh"

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

      I have no plans to leave bash, I have gone back and forth with zsh but bash is home.
      Side note, I have been going through your install script, impressive! I'm looking forward to running it. I make a habit of going through things pretty thoroughly before running them so I have an idea of what should happen and how things should work.

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

      @@JakeLinux
      Thank you for your update! I do recommend you try the installer.remake-v1.0.8.sh first (this is 'type-2' with lack of a better word) because that looks to be my primary candidate, the differences are specified in the README and the Changelogs LOL
      Feel free to give me any inputs and/or constructive criticisms for improvements hahaa

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

      @@uuu12343 I looked at your profile and fivrr, your skills are well beyond my capabilities so not sure I would have any suggestions that a professional like yourself would not already have thought of, but I will let you know if I come up with anything.

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

      @@JakeLinux
      Thanks!
      Naah it's fine, I wouldn't really call myself a professional just yet tbh, I accept all user experience/community input for improvements

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

      @@uuu12343 I have run your script a couple of times now, and I am impressed. It's quick and painless, I like it.

  • @nicolaslarge7545
    @nicolaslarge7545 2 роки тому +2

    Nice. Can't wait to be at the level where I can code on the fly to fix something, and it actually runs without debugging/testing. And yes, "$#" == number of arguments. Just used it to simply one of my if's. ty.

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

      Thanks, it's a rare occasion that things work out like that. Thanks for watching.

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

    👍

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

    Where can I get your bashrc file? Can't seem to locate it on github.

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

      I will push it today

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

      @@JakeLinux Thanks!

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

      @@Octavus5 done, you should be able to find it there now

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

      @@JakeLinux Thanks again, Jake. Got it.

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

    I'm a novice at coding and I'd like to try out this function you created.
    I can alias cd to other keys but I can't figure out how to map/alias cd to Ctrl h.
    Is it really necessary to change cd to Ctrl h in order for this function to work?
    P.S. Your status line setup for vim works on my laptops but not on my desktop.
    Anyway, best of luck mate!

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

      It's not necessary to set Ctrl h it is just easier than typing cd ~ to get home, the function will still work as long as you remove the ability of cd to go home with cd return.

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

      @@JakeLinux Thanks for the reply.
      But, I'd still need to get to home at some
      point and unless I have some alias like
      Ctrl h I'd be stuck. My point was how did you make Ctrl h go to home?
      Here's another conundrum I can't find an
      answer to: How do you map (in vim) the arrow keys to something like Ctrl h, j, k, l while in insert mode. Surely I can't be the only one who gets frustrated when you type in something like: def myFunction(a,b):
      and you have to escape, move, insert to type the colon after the brackets or
      leave the home row to use the arrows!
      I really don't want to disable autocomplete for brackets and quotation marks. Perhaps you could make a video about that if you know or figure it out some time. Cheers!

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

      @@gurmit731 sorry, if you type cd ~, that will get you home, if you go to my GitHub or gitlab page, look in my dotfiles repo and find the .inputrc file, it will show how to set bash key bindings.

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

      @@JakeLinux Your binding didn't work.
      However this does: bind '"\C-h":"cd"'.
      I'm on Linux Mint 20.3 btw.

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

      @@gurmit731I'm surprised, I'm not sure why it wouldn't work, but if you have found a solution, that's great.

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

    Bash will sooner than later be deprecated. And mostly standard shell outside the Linux world. Also a lot more customisable than Bash. I understand why people shouldn’t have Fish as default shell, because actually not a real shell. Luke Smith explains it very well…

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

      I get the draw to zsh and fish, but bash is where it's at, I don't know if I could bring myself to change away from it.

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

      @@JakeLinux I can’t actually see the draw to Fish, but Zsh is just what I got used to and have been using since the beginning. And like Bash, is an actual shell 😊

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

    You're one of these god believers, aren't you? "Praise god", "god bless" ... Here I recommend reading the man page. I was too until I did that.
    Anyway, you might enjoy nnn. Try it out. I prefer nnn -A, because the auto select when doing / annoys me.

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

      I am a Christian, yes. I assume by man page you mean the bible, and I read that daily.
      I think I have nnn installed.but I don't think I ever actually tried it out, I think I installed LF as well, not sure, I got hooked on ranger and didn't leave.

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

      @@JakeLinux If I prove to you your god is evil, will you stop following him?

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

      @@callisoncaffrey So you believe in God but feel He is evil, am I understanding you correctly?

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

      @@JakeLinux No, I say it doesn't make a difference. Because if he exists, than he's clearly evil so I wouldn't follow him in the first place. But you didn't answer my question.

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

      I was just curious what your overall position is, and if it doesn't matter if He exists or not, why you even want to prove to me that He is evil? If you have "proof" that He is evil then share it, and we can discuss it.

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

    Okay, now show me how to get syntax highlighting, like in fish, and I'd be perfectly happy in bash, also. :p

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

      There is a tool for bash called ble.sh on GitHub that gives syntax highlighting

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

    What do you got in MomsSite ha?
    Now I'm more interested in that.

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

      Nothing interesting, just my mom's business website.

  • @comosaycomosah
    @comosaycomosah 6 місяців тому +1

    really like your whole setup dude you have the dot files?

    • @JakeLinux
      @JakeLinux  6 місяців тому +1

      Thank you, I appreciate that. Most, if not all of my configs are in my repos.

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

      i actually went there after i commented this lol what size approx is your void install without your personal stuff im lacking on storage space atm using a computer with a soldered in 32gb emmc and think i need to switch from mint to arch or void or nix just dont know the average size really@@JakeLinux

  • @rsmith31416
    @rsmith31416 2 роки тому +2

    Interesting! To be fair, the poor man's zsh autocompletion in bash is simply adding "\t": menu-complete, "\e[Z": menu-complete-backward, "set show-all-if-ambiguous on" and "set menu-complete-display-prefix on" to your .inputrc file, but I agree this is not the same thing.
    Looking at your improvement, I thought a more restrictive functionality would be to set a shortcut calling a bash function from your .inputrc file (e.g. "\C-o": "cd_\015", with a cd_ function running 'selection=$(find . -maxdepth 1 -type d | fzf); cd "$selection"'. Maybe this is not so useful if you already have plugins to jump to past directories.
    As another alternative, fzf already provides a plugin to cd into directories with alt+c, by calling ___fzf_cd___

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

      Good points, I have a few of those settings in my .inputrc file already. Was unaware of fzf cd command.

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

      @@JakeLinux Or just Ctrl+T if you have sourced its key-bindings.bash file

  • @Bruces-Eclectic-World
    @Bruces-Eclectic-World 2 роки тому +1

    I love this that is a cool function when you add all the ( " ) to them! LOL
    I was setting there yelling "RED ALERT! RED ALERT! " WE Have A "RED ALERT! RED ALERT! " and making the ert ert ert sounds... 🤣🔴⚠
    I don't use bash that much anymore but I do once in a while and I will be adding this to my .bashrc!
    Awesome stuff Jake!
    LLAP 🖖
    "RED ALERT! Adverted" STAND Down! Captain OUT!

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

      Thanks Bruce, I definitely like this one.

    • @Bruces-Eclectic-World
      @Bruces-Eclectic-World 2 роки тому

      @@JakeLinux Now, auto-computation and were golden... 🤣

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

    Praise God?
    Blocked...

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

      Bummer, but no hard feelings

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

    👍 Another fun one!

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

    GVJ, I like it.

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

      Thank you, I am surprised it worked on the first shot.

  • @MrXankiller
    @MrXankiller 4 місяці тому

    Brilliant use of cd and fzf, gonna steal that thanks a lot