 Hello and welcome today. We're going to be looking at putting stuff into your clipboard from a script so if you want to grab the output of an application or Automate grabbing text from a file and putting into your clipboard so you can paste somewhere That's what we're going to do today, and we're going to be using X clip There's other applications. I think they kind of do this like that's called. There's one called X clipboard Which I haven't really messed with X clip is what I normally use And you'll have to install it. So pseudo apt install X clip should do that I already have it installed. So I'm not going to worry about that So again on Debian based systems use wherever package manager like apt apt get aptitude or some gooey Package manager for some reason anyway, so how does X clip work? Well, you can just pipe Files and or text into it and it adds it to your clipboard Now as we talked about in our last video on Linux you have multiple clipboards. You have the one that is As soon as you highlight something is then copied into your clipboard that you can center click to paste and Then there's your standard one that you can you know highlight something and in most cases Control C or if you're in your shell control shift C or you can right click and say copy and at that point Then you can control V control shift V in a shell or right click and say paste So again, if I now highlight this so Fort is in one clipboard if I hit Right click and click paste it clicks Fort it says pastes Fort if I start center-clicking you can see it clicks It pastes what I have highlighted Metal X 1000 forts. So again, we went over that in the last video. So be sure to check that out if you haven't yet So by default X clip puts it into your selection clipboard, which is whatever you have highlighted So let's say I was to echo HTTP colon forward slash forward slash films by Chris comm I can pipe that into X clip And now if I center click it pastes that URL as well as the new line character because echo automatically puts one in So if I don't want that I should build do dash and and now if I paste it doesn't put that new line in But you can you know if I do date just as an example I put that into X clip and now I can center-click and it pastes the date command in there Which is very useful. I can also tell it to look at files and Get the information from files. So first of all, let's really quick look at the X clip Man page which has lots of information in here and some good examples I always say it's not a good man page if it doesn't have good examples and apparently they feel the same way Which is awesome So here are some examples, but we're gonna be looking at getting the content of a file like so so If I was to create a file, I'll just use vim to create a file my temp folder. I'll call it Clip dot text and then I can put some stuff in here. Hello world I'll save that and Then I can just say what you could do you could say cat out that file Into X clip and now I can center-click and it pastes it or you should be able to just tell X clip to look at that file and I believe in the man page says dash T was the option for that But by default if you don't pipe something to do it it go ahead and does that but I've noticed when I do that Yep, so Yeah, so you don't need that dash T. Hello is not a command But you should just be able to give it a file and that works for multiple line files, too So if I was to This is a test I should be able to still tell X clip to Look at that file and now if I center-click it pastes all the lines of that file So it you know just like your clipboard normally would it can hold multiple lines of text So that is putting things into your clipboard next video. We'll look at pulling things out of your clip. Oh, I Almost forgot. So that was your center-click your selection Clipboard you can also tell it to go to another clipboard if you want to go to your clipboard where you press Control V or when you right-click and paste because right-click and paste is still doing what I highlight before and said copy What you can do is so let's just say That we're going to echo that in there. We can do dash selection and we'll say clipboard and That's all I get to put it in the standard clipboard now I can do that and I can right-click and say paste and it pastes that and again if we look at the man file And we do select shall we search through this for selection standard Somewhere in here Target Selection here we go. So the selection It will use your primary or secondary and you can also in here. I believe somewhere where I wrote out the full Clipboard there is a way to abbreviate that Let's see if I can find that pretty sure I read yes, so Note that only first character of a selection specify will With a selection command is important. This means that P sec and clip Will have the same effect as primary secondary and clip So you can shorten that up if you want you can do selection P for your primary And I guess you could just do they don't say it but you should be able to just do selection S or C for the for the other options there So again quick review. I can say just I can pipe something into it So here I'm going to echo my URL into clip X clip and I can now center click to paste if I want to It to go to my other clipboard where I can control V control shift V or right-click and paste I want to tell it dash selection clipboard and you should be able to do that. Yep And just to chat try it out. Let's do this Let's just give it I'll say S. Let's see if I do dash C and if I control shift V Yep, so you don't you don't even need to write out clipboard You just do see there and if you want to go to your other clipboard you just Leave it blank to say X clip anyway again in the next video So we were putting stuff in our clipboard and next week we're gonna be looking at pulling things out of our clipboard So if you copy something or highlight something your script can grab it Which is very useful if you want to have a script do something with text once it's highlighted So we'll look at that next time. I do thank you for watching. Please visit films by Chris calm That's Chris the kid. There's a link in the description. Be sure to check that out You can search through all my videos support me over at patreon.com forward slash mil X 1000 I hope that you have a great day