Page 11 of 15

Re: Post your Command line tricks

Posted: Sat Feb 14, 2015 10:09 pm
by stark

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 12:39 am
by kiiroitori
Thanks to stark I know now that Ctrl+r searches your history recursively. Yes I didn't know that! This command is the dmenu of bash! It's like realizing the sunglasses you were looking for are actually on your forehead and that they are polarized expensive cool as fuck sunglasses! Thanks stark (heart icon here)

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 1:11 am
by dkeg
that's why this thread is so great. So much out there, so much to remember (which none of us can).

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 2:07 am
by Dr_Chroot
Yes, it is all good stuff fo sho! Thanks stark :D (I hadn't the faintest idea about reverse searching history either.)

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 8:12 am
by wuxmedia
wow, yeah you guys need to go through this thread then :P
I was going to moan at simple thread postage, but that seems to have worked.

ctrl-r is massive, combine it with a '#' and a unique line you have a marker.
yes you can comment out on the cmd line.

My fav is alt dot - which is in this and one of those threads too.
All these things make the CLI a lot more friendly

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 1:32 pm
by kiiroitori
wuxmedia wrote:ctrl-r is massive, combine it with a '#' and a unique line you have a marker.
This stuff just keeps getting better. Thanks Wux!

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 7:08 pm
by stark
Thanks Everyone. I'm just trying to stay away from zsh ( no offence ).

https://github.com/revans/bash-it

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 11:35 pm
by pidsley
Can I put a nano tip here? I often load a second file into vim so I can copy a snippet and paste it into the file I'm working on. nano can do this too. I've used this in the past, but so infrequently that I had to look it up every time. I think I can remember it this time.

1. If you are already running nano, turn on multibuffer mode with "alt F" -- if this is something you like and want to use all the time, put "set multibuffer" in your nanorc, or start nano with "nano --multibuffer" or "nano -F".

2. Once you are editing one file, load more files with "ctrl r"

3. To switch between the buffers, use "alt ," and "alt ."

Now you can cut lines from one file and paste them into the other.

http://www.nano-editor.org/dist/v2.2/faq.html#3.7

Finally, if you know you want two (or more) files loaded at once, use "nano <file1> <file2> ..." -- then "alt ," or "alt ." will switch between them.

Thanks to stark for reminding me to look this up and learn it again.

Re: Post your Command line tricks

Posted: Mon Feb 16, 2015 11:51 pm
by wuxmedia
^ that's handy, most of the work installs have vim as default, but some don't. so that's a great way of visually diffing files, or indeed c/p from/to files.
Again. it's nice having your own system as custom as you can make it, but that just doesn't happen in most work environments. Unless you are the CTO...
So always good to know the defaults of bash certainly.

Re: Post your Command line tricks

Posted: Tue Feb 17, 2015 12:46 am
by pidsley
^ "vimdiff <file1> <file2>" is still my favorite way to compare two files (like kernel configs).

Re: Post your Command line tricks

Posted: Tue Feb 17, 2015 1:04 am
by dkeg
so I'm wondering now ....

vim T & T thread?
nano T & T thread?

Re: Post your Command line tricks

Posted: Tue Feb 17, 2015 1:06 am
by pidsley
I am also thinking about tmux T&T ;)

Maybe "non emacs T&T?"

Re: Post your Command line tricks

Posted: Tue Feb 17, 2015 1:15 am
by dkeg
Good timing, I just learned one tmux trick. You can hide the status bar!

Re: Post your Command line tricks

Posted: Wed Feb 18, 2015 10:22 am
by machinebacon
pidsley wrote:Can I put a nano tip here? I often load a second file into vim so I can copy a snippet and paste it into the file I'm working on. nano can do this too. I've used this in the past, but so infrequently that I had to look it up every time. I think I can remember it this time.

1. If you are already running nano, turn on multibuffer mode with "alt F" -- if this is something you like and want to use all the time, put "set multibuffer" in your nanorc, or start nano with "nano --multibuffer" or "nano -F".

2. Once you are editing one file, load more files with "ctrl r"

3. To switch between the buffers, use "alt ," and "alt ."

Now you can cut lines from one file and paste them into the other.

http://www.nano-editor.org/dist/v2.2/faq.html#3.7

Finally, if you know you want two (or more) files loaded at once, use "nano <file1> <file2> ..." -- then "alt ," or "alt ." will switch between them.

Thanks to stark for reminding me to look this up and learn it again.
That's super-neat, thanks for the tip. I only knew about multiple files,but not that new buffers can be created. I should RTFM more :)

Re: Post your Command line tricks

Posted: Thu Apr 09, 2015 8:48 pm
by z3bra
A small, but cool one:

Code: Select all

markdown < body.md | cat header.html - footer.html > index.html
To generate an HTML page out of a markdown page, and add a header/footer meanwhile.

Re: Post your Command line tricks

Posted: Fri Apr 10, 2015 5:40 pm
by doubledutch
One I had to search for last week:
Disk Usage, human readable, 3 folders deep. Feel free to change depth and directory:

Code: Select all

du -ax --max-depth=3 /tmp/ | sort -n | awk '{if($1 > 102400) print $1/1024 "MB" " " $2; else print $0 }'
Generation after generation:

Code: Select all

perl -e '@r=(a..z,A..Z,0..9);$p.=$r[int(rand(@r))],$i++while($i<8);print"$p\n"'
ccrypt is my tool of choice, but I use this in scripts all the time:

encrypt:

Code: Select all

tar zcvf - /home/user | openssl des3 -salt -k secretpassword | dd of=/dev/st0
decrypt:

Code: Select all

openssl des3 -d -k secretpassword < stuff.des3 | tar zxf -
All of that being said, here's a PowerShell gem:

Code: Select all

psexec \\computername cmd
and then

Code: Select all

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
For enabling remote desktop protocol remotely.

Re: Post your Command line tricks

Posted: Sat Apr 11, 2015 12:25 am
by simgin
^ sounds like a hack ;)

Re: Post your Command line tricks

Posted: Sat Apr 11, 2015 9:45 am
by wuxmedia
must have been old (or non-gnu) to use du with no '-h' option?
in the spirit of du'ing;

Code: Select all

 du -sh /dir/ | grep [0-9]G
only find big files.

Re: Post your Command line tricks

Posted: Mon Apr 27, 2015 4:32 pm
by pidsley
Kind of a script (not cli) tip, but if you want to loop a sequence in bash, there is no need to use seq; bash can do this by itself.

Code: Select all

 $ for n in {1..7}; do echo $n; done                                                                                                                                         
1
2
3
4
5
6
7

Re: Post your Command line tricks

Posted: Mon Apr 27, 2015 5:59 pm
by stark
^ Thank You, very nice :)