Plumbing in Linux (à la Plan 9 from Bell Labs)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so at the request of some subscribers and I guess in the interest of experimentation I've started to do something that usually my philosophy goes very much against and that is using the mouse in fact using the mouse of relative totally differently than you've seen it be used before on most operating systems but still it feels a little weird to use the mouse again so let me explain the you may see the video title description I I've started to do plumbing on Linux which I guess I should explain briefly now there is this operating system that looks like this called plan 9 from user space and this is its text editor slash UI / I pretty much does everything now I don't know that much about plan 9 but it's pretty interesting in that the mouse all three buttons of the mouse left middle and right all have an important function and your development environment your text editor are sort of have Mouse the mouse used as a core key to open things up send things to other programs all this kind of stuff so for example if I type I can just type arbitrary text so for example when happens to be a command and if you highlight that and right-click it or it's even middle click it it will actually run the command it's really weird so you can just write a command and run it with the mouse and you know with the middle key or the right key or the right button I should say is often called the plumber or it's a plumb key which can do a whole bunch of things including opening files and just other stuff depending on what you have highlighted so what I wanted to do I've gotten a couple emails recently about this people have been asked I'm not quite sure why maybe just the coincidence but people have been asking for some kind of plumber or plumber ideas for Linux and some people even sent me their own examples so I wanna I wrote a little plumbing script to replicate opening files or dealing with text highlighted with you know in Linux anyway we'll just get into it so I'll go ahead and say it has a pretty cool feature that I'll talk about later but some basic features I want to talk about now so so at a basic level you know let's say I have a terminal document open and of course this could be in the terminal this could be something you have highlighted in Firefox it actually doesn't matter as long as you have that highlighted it's gonna work the same way but I'm using a terminal here so let's say I highlight this text now I have a script that I am using as a plumber bound to super see right now and if I run it what it does is it will give me some options it'll detect first off okay this is what you have highlighted but it'll give me some options for what to do so this is a URL so I'll say go to URL there's something like that so that'll pop up my Internet's actually slow today but the web address will pop up in a browser same thing if I you know have an email address here I can say oh it gives me the option of looks like email so I can open that up in my email client send an email to myself or something like that additionally you may have noticed in the options so for example if I have some kind of location highlighted I can it'll give me a Maps option and that'll actually open it up in a window of OpenStreetMaps if you want that so that'll pop up after a second so you can do of course you can change it to Google Maps if you really want I'm sure you know I don't use Google for anything besides YouTube but that'll do that and additionally you know you can search a bay for something or anything else now that's just opening browser windows that's relatively basic but there's some other things as well so for example here you know here if you have some kind of command let's say said and this could be again I'm in vim but you could be on the command line as well but if you have some kind of command highlighted it'll actually automatically detect that and it'll give you the option of looking at its manual and that'll auto generate a PDF manual and bring it up for you so you can search through it in a different window you know again so you don't have to open up a new window and press a man or something like that just a nice little thing to have now one little note here before I I'm gonna go into how the script works in just a second but I will say one note about vim is um well I'm using neo vim right now I think it might only be a neo vim problem but for whatever reason you're supposed to be able to highlight stuff with the visual mode you know using V or whatever and that's supposed to your primary selection is supposed to be able to read from that if you set a particular option autoload you can look it up your skirt auto select or something like that but in the current build of neo vim it isn't actually working so right now you have to select it with you basically just have to select it with your mouse or whatever but once that gets fixed you can select it with visual mode and vim as well so you don't actually have to even use your mouse so that's just a note okay so let me talk about how this script works but also it's what I think is its best feature so I'm gonna open up here's the script I have it's pretty short it's in bash I usually write things in posix-compliant shell but I had to write this in Bashan I'll explain why or I probably don't actually have to I just don't know how to do this in POSIX shell so the idea behind it is all of the different options for things you can do they're all different functions so web search Wikipedia Wiktionary maps eBay all those kind of things are different functions and what you can do is I don't know if you know this but if you say declare F in bash that will give you a list of all the functions you've declared so I can actually take let's say take the third element of this output and we will put that into D menu and then give it a prompt that says pick a function okay so that will give me a menu of all my functions and that's really what this script does it defines a bunch of functions for with what you can do with output and then it just gives you a list of those so I don't have to redo them every time you know change the options every time I add a new function or something additionally there so for things like email where you're only going to be using I mean I only want the email option if I'm highlighting something that looks like email right so it actually checks first hand before it checks to see does that actually look like an email address same thing with the URL does that actually look like a URL and only if it does exist does it coined the function and then the function will appear oh I I don't think I mentioned before but you can also use you know QR encode to encode some stuff so I can say QR encode and this text is now encoded in that QR code but that only happens if you have QR encode installed now what I think is the most useful function which I've saved for halfway through the video which is probably a bad idea but whatever is this thing here and well I'll just show you how it works first off so I can go to my you know just open up a terminal prompt get an LS here's a list of all my files let's say see I like this file boomer big I wonder what that looks like so I'm gonna press my plum key and you'll see that this file has just opened up it just popped up that's all it's done so instead of actually having to type in Oh what is my image viewer it's s XIV and then tab completing all this you can just highlight it and run the plum key and it automatically opens additionally well actually I'll go ahead and show you basically the ideas if the primary selection is detected as a file just open it in xdg open use whatever your default viewer is for that and works out perfectly the problem is of course if you're in let's say I'm in my downloads directory so I'm gonna get rid of this for a second if I'm in my downloads directory if I were to just run this code it wouldn't detect that file because the the script is running from the home directory so these lines here what they actually do is they take the active window that is this one and tries to detect what directory it's actually in so this terminal right here is now in the Downloads directory so it tries to detect that and then it changes that directory then it attempts to find the file so if I select a file here it will open even though I'm not in the home directory so that's just a little hack to get rid of that there's probably a more elegant way of doing this it's just that's how I had it I have another script doing that as well I mean you may know that in my if you press super shift and enter it'll automatically open a terminal in the same window that you have whatever your active window is open in so that's pretty nice and again you can't so i mean if i LS home i'm not gonna be able to open these files so if i'm from you know my downloads directory so if i try to open that nothing it's not gonna work it's gonna give me the menu but if i CD back to home and then i try it it'll work fine you know which is usually you know there aren't too many times where you that's gonna be a problem but um anyway oh yeah so i've made I made a sed 11q t-shirt merchandise which is down below the description just cuz if you want a shirt for a YouTube channel involving a joke that literally five people get on the channel you can get one now but anyway so that's that and you may notice as well if if it's detected as a file and it's opened it doesn't actually give you the menu to select what you want to do with it it's just inferred that okay this is a file they just want it opened and you don't have to worry about anything else so don't give me the menu of Wiktionary and maps and eBay and all that stuff obviously I don't want to do that but I'm thinking about I don't know I think that's pretty good design but I'll probably play around with the script a little more I was actually thinking about you know if if you highlight an email I might just assume that that email is supposed to be opened in your email you default email application maybe I'll just skip the whole option thing in the same way I skip the options if it looks like a file but I'm not quite sure about that but anyway I'm still sort of playing around with this I am gonna put it on my github I'll push it relatively soon but if you have any suggestions for it it'll probably be up by the time that you see this video but if you have any suggestions feel free to give them to me and as I said with vim and neo vim a neo vim at least visual mode is not working for primary selection I think they just have to fix it I think it's been broken for a long time but you should be able to get it work working in vim if you set Auto Select but um I mean I'm and I'm just talking about using visual modes so you don't even have to use your mouse but um anyway so that's it and it's gonna be default under larva at the super C shortcut and I will see you guys next time
Info
Channel: Luke Smith
Views: 29,922
Rating: 4.9074302 out of 5
Keywords: gnu, linux, tutorial, introduction, unix, philosophy, minimal, minimalism, minimalst, computer, programming, program, i3, i3-gaps, vim, emacs, vi, tex, latex, markdown, git, github, groff, arch, gentoo, distro, distribution, distrobution, ubuntu, fedora, thinkpad, floss, free, open, source, foss, software, plan9, plan 9, userspace, outerspace, acme, plumb, plub, plumbing, key, mouse, bind, maps, click, select, primary, selection, clipboard, url, email, qr code, file, xdg, xdg-open, bell, labs, bell labs, sed 11q, sed, glen, glenda, ed, wood, bunny
Id: RlMxbQmMz_4
Channel Id: undefined
Length: 11min 18sec (678 seconds)
Published: Fri Mar 08 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.