Want A List Of Your Keybindings? Write A Shell Script!

  Рет қаралды 24,234

DistroTube

DistroTube

2 жыл бұрын

I love showing real-world problems being solved through the use of shell scripting. One question I often get is "How can I get complete list of my keybindings for my window manager?" So I will show you how I could quickly write a script to do this for my Xmonad desktop, and you could do the same for any window manager that you use.
NOTE:
I have NOT uploaded the script in this video to my GitLab yet due to an Internet outage (again!). I will try to upload it for you guys tomorrow.
WANT TO SUPPORT THE CHANNEL?
💰 Patreon: / distrotube
💳 Paypal: www.paypal.com/cgi-bin/webscr...
🛍️ Amazon: amzn.to/2RotFFi
👕 Teespring: teespring.com/stores/distrotube
DONATE CRYPTO:
💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
SOCIAL PLATFORMS:
🗨️ Mastodon: distrotoot.com/@derek
👫 Reddit: / distrotube
📽️ LBRY/Odysee: odysee.com/$/invite/@DistroTu...
DT ON THE WEB:
🕸️ Website: distrotube.com/
🐿️ Gemini Capsule: gemini://distro.tube
📁 GitLab: gitlab.com/dwt1
FREE AND OPEN SOURCE SOFTWARE THAT I USE:
🌐 Brave Browser - brave.com/dis872
📽️ Open Broadcaster Software: obsproject.com/
🎬 Kdenlive: kdenlive.org
🎨 GIMP: www.gimp.org/
🎵 Ardour: ardour.org/
💻 VirtualBox: www.virtualbox.org/
🗒️ Doom Emacs: github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys!

Пікірлер: 94
@nikkehtine
@nikkehtine 2 жыл бұрын
I like these kinda videos where the presenter shows the problem and how they solved it, from a purely problem-solving mindset, instead of holding your hand telling you what to do so that you can just copy-paste their code and learn nothing from it
@agushex
@agushex 2 жыл бұрын
Totally agree, when coding mistakes WILL happen, people need to understand that because they tend to believe that if something doesn't work something is going to break... which well can be true in some extreme cases like it happen to me yesterday but if you're just playing with sed and grep it's okay xD
@temudjin1155
@temudjin1155 2 жыл бұрын
That is what I like when I watch your videos : You make mistakes and you show how to deal with the problems. Great man
@freedombsd2539
@freedombsd2539 2 жыл бұрын
AwesomeWM Windows Manager is not as Awesome as Derek's tips and tutorials! I no longer fear the terminal and scripts. Thank you for my daily dose of DT.
@Noukkis
@Noukkis 2 жыл бұрын
You can get rid of the invert grep by using '^\s*, ("' instead of ', ("' o the first one, or even simply '^, ("' if you get rid of the spaces first. And also, you can use \s instead of [\t ] in sour sed command (\s basically means "all stuff that looks like a space but might not actually be that actual character")
@yoannguillard6877
@yoannguillard6877 2 жыл бұрын
So something like this : ^\s*[[,] (" Would do complete job !
@jeremywhetzel4007
@jeremywhetzel4007 2 жыл бұрын
What a great idea! That's been the one thing that's made it hard for me to get into tiling window managers, and it never occurred to me to just parse the bindings out of the config file. Thanks for showing how easy it can be!
@Zoltar358
@Zoltar358 2 жыл бұрын
Ingenious. I think you should make more videos like that.
@matthewmiller3630
@matthewmiller3630 Жыл бұрын
Distro, you are an underreated teacher. Thanks for these great videos.
@fakharhaider2357
@fakharhaider2357 2 жыл бұрын
Just the video I needed, I literally subbed to this channel so that I can learn a bit about Linux before switching to it, nice to see that this channel actually gives you the content you need, awesome video keep it up, I Hope you make a video about sudo and other command previleges and how to remember them just like this method Thanks
@edwardsmith1237
@edwardsmith1237 2 жыл бұрын
A very nice tutorial, DT, and a great way to show less confident users that you can make nice and useful scripts by starting with an idea of what you want to achieve, and then working thru the steps bit by bit. I like how you tested each step before proceeding to the next one. Yes, I'm sure the super duper ninja scripters will (and have) point out faster ways of doing this, but that's missing the point. Keep up the good work!
@Danielddiniz
@Danielddiniz 2 жыл бұрын
Derek You always anticipate our needs my friend! Thanks 😊 🙏🏻 as always for the video and your teaching skills are amazing!
@12Q46HPRN
@12Q46HPRN 2 жыл бұрын
Thanks for introducing yad. I appreciate these little utility programs. Please introduce more of these as you see fit.
@IvicaAnteski
@IvicaAnteski 2 жыл бұрын
thank you DT, just what I needed!
@snipzmattio5887
@snipzmattio5887 2 жыл бұрын
This is a amazing idea/video! Thank you so much
@justjie1008
@justjie1008 2 жыл бұрын
I really like how your terminal looks as it shows terminal with having the word “terminal” on the top
@Chris-ip8uv
@Chris-ip8uv 2 жыл бұрын
Good stuff, DT. Thank you!
@whale5086
@whale5086 2 жыл бұрын
Awesome vid! Taught me a few neat tricks. Wasn't aware of the Yad program either, and I've been looking for something exactly like that for one of my own scripts! Thanks :)
@BenitoF2009
@BenitoF2009 2 жыл бұрын
Hey DT! Thank you very much! That came exactly at the right time! 👍 And it works great with xfce. I only just had to change the file to read from and some commands.
@indrajitsarkar3169
@indrajitsarkar3169 2 жыл бұрын
great timing, I was looking for a solution to this exact problem
@YannMetalhead
@YannMetalhead Жыл бұрын
Fantastic video.
@megabates9016
@megabates9016 2 жыл бұрын
Great video, thx 👍👍
@FedoraRose
@FedoraRose 2 жыл бұрын
Man that’s really helpful 😂👌
@himalpoudel7558
@himalpoudel7558 2 жыл бұрын
This is what I wanted forever
@clayotissmith158
@clayotissmith158 2 жыл бұрын
I am personally a huge fan of using grep like: grep (-v) "first pattern\|second pattern\|third pattern" Rather than multiple grep commands or splitting it between multiple lines. I know that Linux source commits mandate lines be less than 100 columns, but damn is bash hard to read when split between multiple lines with how terse it is. I just wish see had a similar technique to prevent a large sed command from being so hard to read and follow.
@beardog5245
@beardog5245 2 жыл бұрын
That was awesome
@Jeff_Seely
@Jeff_Seely 11 ай бұрын
I am really enjoying the DTOS config and this is a good piece to the key bindings puzzle😁. And Awesome is very aptly named. Being rather new to TWM I find it quite a bit easier to hop around on. All good things though 👍
@torsten.breswald
@torsten.breswald 2 жыл бұрын
parsing through a text file, transform the text and put it out, that screams for awk, and you can use awk for everything i learned on a channel called distrotube, maybe you've heard of ^^ i'm just to lazy right now to tinker it out myself, but i would try to filter for "spawn" then set the delimiter to the double quote " to have like 4 fields, strip away some unneeded stuff and give that to yad, yea as i think about it, it wouldn't be any shorter then, so many ways lead to rome i guess i appreciate you leaving your fails in the video, often times these mistakes help me more than just the run over the script
@JuanPerez-iu9vk
@JuanPerez-iu9vk Жыл бұрын
Thank you
@jrlepage
@jrlepage 2 жыл бұрын
@DT this was amazing!! Btw, how much caffeine did you consume before recording this? 😂
@fauzirfandika
@fauzirfandika 2 жыл бұрын
Hey DT, great vid as usual! I've been trying to record a video/podcast (linux related stuffs, in my language) and having trouble with the speech (kinda nervous and all), any tips on that? Do you make script about the topics? I would love to see and learn how you do the creative process (mainly pre-recording stuffs like topic research, script writing, etc) on making a video!
@SilentFire08
@SilentFire08 2 жыл бұрын
I see you changed your audio recommed audio software from audacity to ardour can you make a video about it?
@florianfelix8295
@florianfelix8295 2 жыл бұрын
A true real world problem :D
@elys7563
@elys7563 2 жыл бұрын
Can we make some(4-5) keybinding script and show it in yad and by select any script would show the particular dialogue? Like in qutebrowser
@INeedAttentionEXE
@INeedAttentionEXE 2 жыл бұрын
I can probably do the same thing with dwm's header, this is a fun idea!
@MrQwebek
@MrQwebek 2 жыл бұрын
Is it like when you love your old car and keep upgrading it instead of switching to new one and live further?
@GodIsTheReason
@GodIsTheReason 2 жыл бұрын
This is a fun idea for someone who already likes tinkering with TWMs and shell scripts, but honestly... I don't think you're going to convince anyone else to start using TWMs and shell scripting with this video ;)
@RAndrewNeal
@RAndrewNeal 2 жыл бұрын
Before getting 5 minutes into the video, I paused it and did it for my i3 config file. I colored all the output to make it easy to read. But since I colored it with ANSI escape codes, I couldn't properly display it in YAD, so it displays in the terminal.
@bostickdoesmusic1746
@bostickdoesmusic1746 2 жыл бұрын
I always just write out a text file called like .keyhelp or something and list all the keybindings there. Then I alias it in my zshrc with cat so "keyhelp" just pops them out in the terminal for me.
@Phydoux2112
@Phydoux2112 2 жыл бұрын
Great stuff! I love shell scripting! Yad is a new one for me. I'll have to play around with that one of these days. Looks pretty slick. BTW, I'm running AwesomeWM and I tried the holding the Super Key and the shortcuts did not come up.
@ZuluEchoRomeoOscar
@ZuluEchoRomeoOscar 2 жыл бұрын
Super + 's' in the default config I believe...
@Phydoux2112
@Phydoux2112 2 жыл бұрын
@@ZuluEchoRomeoOscar thanks. I'll try that when I get home tonight.
@stevie1da_
@stevie1da_ 2 жыл бұрын
I have a little script in my qtile build that generates a markdown file with all my keybinds whenever I restart qtile. I also have a bind that opens that markdown file in a viewer for a quick help menu!
@krzysztofwaleska
@krzysztofwaleska 2 жыл бұрын
Do you share it somewhere? I would be very much interested in something like this. MarkDown sounds like very good idea. Qtile lacks functionality in that region.
@lamprospitsillou6325
@lamprospitsillou6325 2 жыл бұрын
Can you please do a video on yad? There isn't much online and my imagination goes wild from the uses i can think in scripts!
@hamzab1821
@hamzab1821 2 жыл бұрын
Make more of this worflow video. awesome
@TON-vz3pe
@TON-vz3pe 2 жыл бұрын
Shell script is pretty easy to write once practice.
@XenHat
@XenHat 2 жыл бұрын
Nice! You really need to up your regex game though, DT.
@TheJustinist
@TheJustinist 2 жыл бұрын
@@detboi2287 But is really powerful even with just the basics
@dkosmari
@dkosmari 2 жыл бұрын
I was going to comment something like this, but he's actually teaching a very useful way to build up a regex by iteration. Instead of having to think how to combine multiple regexes, it's easier to just supply them separately.
@gerarddelapatefeuilletee4063
@gerarddelapatefeuilletee4063 2 жыл бұрын
I wonder if I have a hearing problem or a vision problem: I hear you say that you use emacs, but what I see is vim and its typical keystrokes. Anyways, thanks for the scripting tips and tricks, I must see that yad thing.
@maskedredstonerproz
@maskedredstonerproz 2 жыл бұрын
11:11 Can't you pipe everything through awk, and then use that to print the keybindings and what they are used for??
@act.13.41
@act.13.41 2 жыл бұрын
He stated in the video that he could have done it in awk, but viewers have been asking for things done other ways. This was done for the noobs (like me) who don't know awk.
@soanvig
@soanvig 2 жыл бұрын
I would print this as table using column command
@j777111able
@j777111able 2 жыл бұрын
3+ people with perfect memories disliked this video. 🤷‍♂️
@terrydaktyllus1320
@terrydaktyllus1320 2 жыл бұрын
More like three self-entitled people with parents that didn't say the word "no" enough to them in their formative years.
@dougtilaran3496
@dougtilaran3496 2 жыл бұрын
XFCE rules the key game.
@GreyDeathVaccine
@GreyDeathVaccine 2 жыл бұрын
XML file?
@MsAlfred1996
@MsAlfred1996 2 жыл бұрын
Where can I learn all this programs like grep, sed and such ?? How do I know how many of these are ??
@foobars3816
@foobars3816 2 жыл бұрын
learn regex ask they all just use that.
@MsAlfred1996
@MsAlfred1996 2 жыл бұрын
@@foobars3816 What is "regex" ?
@noferblatz
@noferblatz 2 жыл бұрын
Wouldn't it have been easier to just use "spawn" for your search criteria? Is that guaranteed to catch all the key bindings?
@DistroTube
@DistroTube 2 жыл бұрын
The "spawn" isn't used in all keybindings.
@leviticus8930
@leviticus8930 2 жыл бұрын
Dude, who do you use for internet? I would have done gone Nick Saban on them.
@ejbully
@ejbully 2 жыл бұрын
In all honesty After I remeber my binds They are similar across $USER I sort of like the mysteriousisty of not having a handicap. Only I know my shortcuts. It doesn't need to advertised. BUT regardless scripting is ALWAYS fun
@jondow1988
@jondow1988 2 жыл бұрын
its diffcult if you have keybindings all around your config files. maybe awk is a better option to do that. since it process line by line all the file.
@jondow1988
@jondow1988 2 жыл бұрын
very easy with awk interpreter. just get the patterns you wanna grab, and awk will output all lines matching those patterns. and also you can use awk interpreter. no need to use the shell. an awk script would be nice.
@misterchief5378
@misterchief5378 2 жыл бұрын
dwm lists all the keybindings in config.h
@FreeRoger
@FreeRoger 2 жыл бұрын
5th! I mean 3rd!
@FreeRoger
@FreeRoger 2 жыл бұрын
@Hai Red i was doing a monty python reference
@bullpup1337
@bullpup1337 7 ай бұрын
I would have used awk I think.
@dkosmari
@dkosmari 2 жыл бұрын
"So what's the best way to do this" is how you start on the wrong foot, as a shell script programmer. The time to second guess yourself is after the point of no return.
@terrydaktyllus1320
@terrydaktyllus1320 2 жыл бұрын
Nonsense! That's exactly how you ***DO*** write a shell script - you decide what the problem is you want to solve, and that start thinking about the best ways to do each part. And what do you mean by "second guess yourself"? How can you "guess" something that is already inside your own head anyway? How many shell scripts have you written? Not too many by the sound of it, if you spend that much time faffing about.
@Tn5421Me
@Tn5421Me 2 жыл бұрын
tfw DT isn't a Haskell Witch
@ananthuskumar1286
@ananthuskumar1286 2 жыл бұрын
use regex instead of 2 grep, ^
@terrydaktyllus1320
@terrydaktyllus1320 2 жыл бұрын
Why? He's trying to solve a problem, not impress someone looking over his shoulder with his coding expertise. Once a script works and you've solved the problem that you need to solve, then you can keep going back to it later and refining it. If you're always trying to "impress your friends", you'll never get anything finished.
@killistan
@killistan 2 жыл бұрын
Performance wise (not that it matters), I think you could do all of that with a single invocation of sed. Sanity wise, maybe Perl would be a good fit for this?
@foobars3816
@foobars3816 2 жыл бұрын
dear god no!
@tetbundy5683
@tetbundy5683 2 жыл бұрын
Use column -s ',' -t to get a nice table format instead of substituting with colon Not respected by yad tough :(
@moutasim_ayoubi
@moutasim_ayoubi 2 жыл бұрын
First
@DistroTube
@DistroTube 2 жыл бұрын
Confirmed!
@jrlepage
@jrlepage 2 жыл бұрын
Doh did ya beat me? Haha congrats 🎊
@moutasim_ayoubi
@moutasim_ayoubi 2 жыл бұрын
@@jrlepage Haha Gg
@FekuEntertainmentLtd
@FekuEntertainmentLtd 2 жыл бұрын
Why not just use an inverse grep, with pattern "\-\- *" and remove all comments.
@alexzander__6334
@alexzander__6334 2 жыл бұрын
please update video title to mention that these keybindings are ONLY for xmonad
Fix Your Shell Scripts With Shellcheck
11:18
DistroTube
Рет қаралды 13 М.
What Are Linux Users Putting In Their Config Files?
31:47
DistroTube
Рет қаралды 91 М.
МАМА И STANDOFF 2 😳 !FAKE GUN! #shorts
00:34
INNA SERG
Рет қаралды 4,8 МЛН
A clash of kindness and indifference #shorts
00:17
Fabiosa Best Lifehacks
Рет қаралды 21 МЛН
🌊Насколько Глубокий Океан ? #shorts
00:42
My 5 Favorite Linux Shell Tricks for SPEEEEEED (and efficiency)
11:06
Getting Started With Git and GitLab
24:34
DistroTube
Рет қаралды 41 М.
I Think I Like AppImages More Than Snaps And Flatpaks
14:15
DistroTube
Рет қаралды 29 М.
Turn Your Window Manager Into A Desktop Environment
16:47
DistroTube
Рет қаралды 137 М.
Solve Problems With Shell Scripting And Dmenu
18:26
DistroTube
Рет қаралды 31 М.
Two Powerful Command Line Utilities 'cut' And 'tr'
15:18
DistroTube
Рет қаралды 32 М.
Get Rid Of That Bloated Desktop Environment And Install Openbox
32:50
Where Does Bad Code Come From?
42:21
Molly Rocket
Рет қаралды 185 М.
Xargs Should Be In Your Command Line Toolbag
16:24
DistroTube
Рет қаралды 96 М.
5 Myths about Watercooling that are WRONG!
24:02
JayzTwoCents
Рет қаралды 162 М.
Clicks чехол-клавиатура для iPhone ⌨️
0:59
PART 52 || DIY Wireless Switch forElectronic Lights - Easy Guide!
1:01
HUBAB__OFFICIAL
Рет қаралды 35 МЛН
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 719 М.