![]() |
|
Neat terminal trick - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: Neat terminal trick (/Thread-Neat-terminal-trick) Pages:
1
2
|
Neat terminal trick - Inori - 12-08-2016 I find myself copy-pasting from my terminals (in both Windows and Linux) fairly often, whether to google errors or grab some sample output from a program. I also often find myself screwing this up and missing a few characters or performing the wrong action (i.e., hitting Ctrl+C on Linux because I'm used to Cygwin), but no more! On windows, piping a command's output the the "clip" command will copy both standard output and standard error streams to your clipboard, and the same goes on linux with the "xclip" command, provided you have the X11 GUI installed somewhere (fun fact: also works over SSH). Example: Code: ; Windows
> echo some text and stuff|clip
# Linux
$ cat some.file|xclipRE: Neat terminal trick - Panther_ - 12-08-2016 Wew that's pretty cool. Had to install xclip but that 'aight pretty sick. Had to make this change to make it work on my system and then made a command for it. Code: echo hello | xclip -selection clipboard -iOn the topic of neat terminal tricks, !! re uses the last command entered in bash. Very use full if you forget to sudo something Code: [lain@navi:~]$ gparted
Root privileges are required for running gparted.
[lain@navi:~]$ sudo !!
sudo gparted
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for lain:It's all simple stuff but if you don't know it, and then you do it makes things much better! RE: Neat terminal trick - bitm0de - 12-08-2016 You definitely have them reversed. cat is Linux, not Windows, and you would normally use echo on Windows... This is a well known "trick" in batch scripting too.. RE: Neat terminal trick - DarkMuse - 12-08-2016 Wow. I'm surprised I never came across this! Thanks man; it's much appreciated. RE: Neat terminal trick - Inori - 12-08-2016 (12-08-2016, 01:42 AM)bitm0de Wrote: You definitely have them reversed. cat is Linux, not Windows, and you would normally use echo on Windows... Seriously? Huh, I thought cat was a Windows thing as well. Guess I've been using Cygwin too much. Either way, the syntax what I was trying to demonstrate. Fixing post. RE: Neat terminal trick - Pikami - 12-08-2016 Doesn't work on XP Code: C:\Documents and Settings\User>echo a | clip
'clip' is not recognized as an internal or external command,
operable program or batch file.RE: Neat terminal trick - pvnk - 12-08-2016 Thank you for this neat terminal trick. RE: Neat terminal trick - bitm0de - 12-08-2016 (12-08-2016, 04:07 PM)Pikami Wrote: Doesn't work on XP Lots of batch scripting stuff at a core level was changed from > XP, in addition to the utility programs available for use. RE: Neat terminal trick - Inori - 12-08-2016 (12-08-2016, 04:07 PM)Pikami Wrote: Doesn't work on XP As @bitm0de said, Batch core and out of the box utilities have changed drastically since XP. On that note, XP support was discontinued over two years ago, so no wonder it's not up to snuff
RE: Neat terminal trick - Pikami - 12-08-2016 (12-08-2016, 09:16 PM)Inori Wrote:(12-08-2016, 04:07 PM)Pikami Wrote: Doesn't work on XP Yeah but they added support for XP in powershell and it runs perfectly |