Want A List Of Your Keybindings? Write A Shell Script!
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: https://www.patreon.com/distrotube
💳 Paypal: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=derek%40distrotube%2ecom&lc=US&item_name=DistroTube&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
🛍️ Amazon: https://amzn.to/2RotFFi
👕 Teespring: https://teespring.com/stores/distrotube
DONATE CRYPTO:
💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
SOCIAL PLATFORMS:
🗨️ Mastodon: https://distrotoot.com/@derek
👫 Reddit: https://www.reddit.com/r/DistroTube/
📽️ LBRY/Odysee: https://odysee.com/$/invite/@DistroTube:2
DT ON THE WEB:
🕸️ Website: http://distrotube.com/
🐿️ Gemini Capsule: gemini://distro.tube
📁 GitLab: https://gitlab.com/dwt1
FREE AND OPEN SOURCE SOFTWARE THAT I USE:
🌐 Brave Browser – https://brave.com/dis872
📽️ Open Broadcaster Software: https://obsproject.com/
🎬 Kdenlive: https://kdenlive.org
🎨 GIMP: https://www.gimp.org/
🎵 Ardour: https://ardour.org/
💻 VirtualBox: https://www.virtualbox.org/
🗒️ Doom Emacs: https://github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys!
Distro, you are an underreated teacher. Thanks for these great videos.
That was awesome
Why not just use an inverse grep, with pattern "– *" and remove all comments.
Derek You always anticipate our needs my friend! Thanks 😊 🙏🏻 as always for the video and your teaching skills are amazing!
thank you DT, just what I needed!
dwm lists all the keybindings in config.h
tfw DT isn't a Haskell Witch
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.
Great video, thx 👍👍
Dunno why, but YouTube got rid of my previous post with the solution, but here it is again. Here's the thing rewritten in awk (excluding the yad stuff), and also gets rid of the extra space on the very first line:
awk 'BEGIN { group = "awkinitialization" }
/START_KEYS/ { flag = 1 }
/END_KEYS/ { flag = 0 }
/KB_GROUP/ {
if(group != "awkinitialization")
printf("n")
sub(/s*–s*KB_GROUP /, "")
group = $0
print
}
flag && /^s*[,[] (/ {
sub(/s*[,[] /, "")
sub(/, /, "t: ")
print
}' ~/.xmonad/xmonad.hs
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!
Shell script is pretty easy to write once practice.
Is it like when you love your old car and keep upgrading it instead of switching to new one and live further?
please update video title to mention that these keybindings are ONLY for xmonad
I really like how your terminal looks as it shows terminal with having the word “terminal” on the top
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.
That is what I like when I watch your videos : You make mistakes and you show how to deal with the problems. Great man
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!
Dude, who do you use for internet? I would have done gone Nick Saban on them.
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 🙂
U can pipe it through fzf and make the keybindings searchable!
Thanks for introducing yad. I appreciate these little utility programs. Please introduce more of these as you see fit.
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.
I'm still using awesome! For now…
I can probably do the same thing with dwm's header, this is a fun idea!
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.
Make more of this worflow video. awesome
Wouldn't it have been easier to just use "spawn" for your search criteria? Is that guaranteed to catch all the key bindings?
11:11 Can't you pipe everything through awk, and then use that to print the keybindings and what they are used for??
Use
column -s ',' -t
to get a nice table format instead of substituting with colon
Not respected by yad tough 🙁
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
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 😉
3+ people with perfect memories disliked this video. 🤷♂️
You can add local exceptions to smart parens in emacs for special modes 🙂 , probably there is something that can recognize regexps, too
A true real world problem 😀