Post your Command line tricks

Forum rules
Share your brain ;)
User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Thu Jan 16, 2014 11:25 am

i did try an underscore deliminator in my cruddy little script, but I couldn't make it work, surprise... I like the way backslashes makes it look like my former avatar. \/\//\/\ :)
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: Post your Command line tricks

Unread post by rhowaldt » Thu Jan 16, 2014 12:05 pm

knew this, but recently came across an old sed line of mine which used it and was thoroughly confused :D
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
xaos52
The Good Doctor
Posts: 190
Joined: Thu Aug 15, 2013 11:59 am
Location: Eernegem, Belgium

Re: Post your Command line tricks

Unread post by xaos52 » Tue Jan 28, 2014 6:46 pm

Alternative to chroot:

Suppose you can't boot into one installed system, but you have one or more other systems installed on that machine:
Boot into another install that still boots OK, then
Mount the system that will not boot on a mount point, e.g /mnt/sushi
Run the command

Code: Select all

sudo systemd-nspawn -D /mnt/sushi
and this drops you into the sushi install where you can investigate what's wrong and try to remedy it.

Found in this post: https://lists.debian.org/debian-user/20 ... 01405.html

Needs systemd on the system you can boot, and probably on the system that needs rescuing also.
Connected. Take this REPL, brother, and may it serve you well.

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: Post your Command line tricks

Unread post by franksinistra » Sun Feb 02, 2014 12:56 pm

my favorite script whenever i got absolutely bored

$ yes penis
rice no more.

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: Post your Command line tricks

Unread post by johnraff » Mon Feb 10, 2014 5:22 pm

Of course you all know this already, but if you don't want a command to go in your bash history start it with a space.
All code is one.

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: Post your Command line tricks

Unread post by johnraff » Mon Feb 10, 2014 5:41 pm

Toggle Conky (or any other process).
I wanted to have conky come up with a keypress instead of being up all the time, but hidden behind windows. (Edit conkyrc to have it on top, maybe give it a background colour too.)

At first I was trying to do this with PIDs stored in files, child processes and the like. It's messy. If conky forks itself into the background (which it can easily) you've lost control of it. If it crashes (eg by messing with conkyrc) it leaves an invalid pidfile. If you have more than one instance of conky running (I have 4) ...

The answer was pkill, with -f option to check the whole command line and -x for an exact match. Simple one-liner (apart from setting $command):

Code: Select all

command='conky -q'
#command="urxvt -e tail -f $HOME/.xsession-errors"
pkill -fx "$command" || $command &
Tie it to your chosen key.

PS There's no way to get Openbox to respond to a key release event is there?
Last edited by johnraff on Fri Feb 14, 2014 5:34 pm, edited 1 time in total.
All code is one.

User avatar
ivanovnegro
Minister of Truth
Posts: 5450
Joined: Wed Oct 17, 2012 11:12 pm

Re: Post your Command line tricks

Unread post by ivanovnegro » Mon Feb 10, 2014 6:50 pm

johnraff wrote:Of course you all know this already, but if you don't want a command to go in your bash history start it with a space.
I was not aware of this, thanks John.

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Mon Feb 10, 2014 7:52 pm

finally I can be the 'ghost in the system' 8) (space)scp -r allthisgoodstuff/ server:/home/wux/
No one will ever know...
"Seek, and Ye shall find"
"Github | Chooons | Site"

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Post your Command line tricks

Unread post by machinebacon » Tue Feb 11, 2014 3:05 am

start with 7 conks, toggle them invisible, make scrot of ultra-minimal desktop and post it here, then toggle back to visible, be the star a bbq forums without losing the comfort of knowing the exact temperature of your floppy drive :D
..gnutella..

User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Re: Post your Command line tricks

Unread post by DebianJoe » Tue Feb 11, 2014 9:01 am

@JohnRaff: The short answer to 'can you get a keyup event in OB' is "Yes." It doesn't matter what the wm is, keyups always exist. As far as adding them to your scripts, Python has some fantastic abstractions to make it easier to access them without having to actually dig into the back-end of it. While not the simplest of solutions, and it will certainly cause some extra overhead, I don't see "minimal resource usage" being high on the list for this particular purpose.

>This basic curses concept should lead you towards the answers you seek.<
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: Post your Command line tricks

Unread post by rhowaldt » Tue Feb 11, 2014 9:56 am

^^ XD
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: Post your Command line tricks

Unread post by johnraff » Fri Feb 14, 2014 5:41 pm

DebianJoe wrote:@JohnRaff: The short answer to 'can you get a keyup event in OB' is "Yes." It doesn't matter what the wm is, keyups always exist. As far as adding them to your scripts, Python has some fantastic abstractions to make it easier to access them without having to actually dig into the back-end of it.While not the simplest of solutions, and it will certainly cause some extra overhead,
I don't see "minimal resource usage" being high on the list for this particular purpose.
>This basic curses concept should lead you towards the answers you seek.<
Thanks for the link Joe. Guess I'll have to get down and study Python one of these days...

In the specific conky case above, at first I thought I'd like it to appear only when the key was down, but on reflection (and realizing I didn't know how to access the keyup event) toggling on keypresses seemed better.

edit:
I don't see "minimal resource usage" being high on the list for this particular purpose.
Actually, come to think of it, that was one of the motivations - only to measure the floppy disk drive temperature when I wanted to know it. I don't really see having a python app running continuously in the background just to switch conky on and off. Openbox (and some other WMs presumably) will respond to key events defined in rc.xml without any other assistance - but not keyup events I guess.
All code is one.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Post your Command line tricks

Unread post by machinebacon » Sun Feb 23, 2014 4:51 pm

Code: Select all

wget -qO - http://freegeoip.net/xml/$1 | sed '3,12!d;s/<//g;s/>/: /g;s/\/.*//g' 
You gonna cry :)
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: Post your Command line tricks

Unread post by GekkoP » Sun Feb 23, 2014 7:08 pm

Wrong city on mine, but cool! :)

User avatar
ivanovnegro
Minister of Truth
Posts: 5450
Joined: Wed Oct 17, 2012 11:12 pm

Re: Post your Command line tricks

Unread post by ivanovnegro » Mon Feb 24, 2014 12:08 am

Everything was correct.

User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Re: Post your Command line tricks

Unread post by DebianJoe » Wed Mar 19, 2014 11:56 pm

Code: Select all

$-> factor
I just ran across this one, but it takes numbers and breaks them down to the prime factors that make them up. Prime numerals are themselves. Something like "12" is "2 2 3".

Runs interactive if not provided arguments, or takes a command line argument to break into factors.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Post your Command line tricks

Unread post by wuxmedia » Mon Apr 14, 2014 1:31 pm

machinebacon wrote: Neat one similar to !!:* is pressing "Alt ." or "Esc ."

Code: Select all

cd /some/ultra/long/path/to/some.file
cp [Alt] + [.] /new/path/
performs a

Code: Select all

cp /some/ultra/long/path/to/some.file /new/path/
Additional: I found out by accident multiple taps of 'alt + .' uses its own little history.

watch out, it simply takes the last whitespace delimited 'word' - might find a few odd things in there.
Seems it keeps multiple entries as well.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: Post your Command line tricks

Unread post by johnraff » Mon Apr 21, 2014 6:41 am

For those too lazy to learn gimp's filters and stuff...
If you're bloated out enough to have xscreensaver installed along with xscreensaver-data-extra then you have vidwhacker.
/usr/lib/xscreensaver/vidwhacker will do random weird things to an image it finds and output it as a pnm image. No need to worry about pnm, whatever that is, imagemagick knows how to display it or convert it to something usable. By default vidwhacker grabs an image from whatever directory you set xscreensaver to use, but you can tell it to use another one. So you can do things like:

Code: Select all

/usr/lib/xscreensaver/vidwhacker -directory ~/images/bandpics  -stdout > whacked.pnm
/usr/lib/xscreensaver/vidwhacker -directory ~/images/bandpics  -stdout | convert - whacked.jpg
/usr/lib/xscreensaver/vidwhacker -directory ~/images/bandpics  -stdout | display -
while true; do { /usr/lib/xscreensaver/vidwhacker -directory ~/images/bandpics  -stdout | display - ; } ;  done
to get psychedelic band member pictures or whatever. Just keep going till it comes up with something usable... or you get fed up.
All code is one.

pidsley
Hermit
Posts: 2539
Joined: Wed Oct 17, 2012 12:31 pm

Re: Post your Command line tricks

Unread post by pidsley » Wed May 07, 2014 10:37 pm

Maybe everyone else already knows this, but I just learned it.

<prefix> + z in tmux maximizes the current pane. <prefix> + z returns it to its previous place.

(<prefix> is ctrl-b in unmodified tmux, ctrl-a in my modified config)

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: Post your Command line tricks

Unread post by dkeg » Wed May 07, 2014 10:59 pm

No, I didn't. Nice one.

Work hard; Complain less

Post Reply