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
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!
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.
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.
Really appreciate your videos, Thanks for making them.
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
Thank you, I like figuring out little tricks like this.
You coukd use ls to list directories only, but that's quite cool as well.
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.
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.
I wonder why you did not use the ** TAB that comes with fzf. Why it does not work optimally for you?
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 )
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 : )
@@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! 😄
Finally, time to add-on to my "reasons to justify staying with Bash and not Switch to zsh"
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.
@@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
@@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.
@@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
@@uuu12343 I have run your script a couple of times now, and I am impressed. It's quick and painless, I like it.
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.
Thanks, it's a rare occasion that things work out like that. Thanks for watching.
👍
Where can I get your bashrc file? Can't seem to locate it on github.
I will push it today
@@JakeLinux Thanks!
@@Octavus5 done, you should be able to find it there now
@@JakeLinux Thanks again, Jake. Got it.
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!
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.
@@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!
@@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.
@@JakeLinux Your binding didn't work.
However this does: bind '"\C-h":"cd"'.
I'm on Linux Mint 20.3 btw.
@@gurmit731I'm surprised, I'm not sure why it wouldn't work, but if you have found a solution, that's great.
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…
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.
@@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 😊
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.
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.
@@JakeLinux If I prove to you your god is evil, will you stop following him?
@@callisoncaffrey So you believe in God but feel He is evil, am I understanding you correctly?
@@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.
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.
Okay, now show me how to get syntax highlighting, like in fish, and I'd be perfectly happy in bash, also. :p
There is a tool for bash called ble.sh on GitHub that gives syntax highlighting
What do you got in MomsSite ha?
Now I'm more interested in that.
Nothing interesting, just my mom's business website.
really like your whole setup dude you have the dot files?
Thank you, I appreciate that. Most, if not all of my configs are in my repos.
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
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___
Good points, I have a few of those settings in my .inputrc file already. Was unaware of fzf cd command.
@@JakeLinux Or just Ctrl+T if you have sourced its key-bindings.bash file
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!
Thanks Bruce, I definitely like this one.
@@JakeLinux Now, auto-computation and were golden... 🤣
Praise God?
Blocked...
Bummer, but no hard feelings
👍 Another fun one!
Glad you liked it.
GVJ, I like it.
Thank you, I am surprised it worked on the first shot.
Brilliant use of cd and fzf, gonna steal that thanks a lot