Post your Command line tricks
Forum rules
Share your brain ;)
Share your brain ;)
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: Post your Command line tricks
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. \/\//\/\ :)
Re: Post your Command line tricks
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.
Re: Post your Command line tricks
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
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.
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
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.
- franksinistra
- Ivana Fukalot
- Posts: 1093
- Joined: Mon Jan 27, 2014 2:03 am
- Location: 印尼国
Re: Post your Command line tricks
my favorite script whenever i got absolutely bored
$ yes penis
$ yes penis
rice no more.
Re: Post your Command line tricks
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.
Re: Post your Command line tricks
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):Tie it to your chosen key.
PS There's no way to get Openbox to respond to a key release event is there?
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 &
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.
- ivanovnegro
- Minister of Truth
- Posts: 5450
- Joined: Wed Oct 17, 2012 11:12 pm
Re: Post your Command line tricks
I was not aware of this, thanks John.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.
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: Post your Command line tricks
finally I can be the 'ghost in the system' 8) (space)scp -r allthisgoodstuff/ server:/home/wux/
No one will ever know...
No one will ever know...
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Post your Command line tricks
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..
Re: Post your Command line tricks
@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.<
>This basic curses concept should lead you towards the answers you seek.<
Re: Post your Command line tricks
^^ 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.
Re: Post your Command line tricks
Thanks for the link Joe. Guess I'll have to get down and study Python one of these days...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,>This basic curses concept should lead you towards the answers you seek.<I don't see "minimal resource usage" being high on the list for this particular purpose.
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:
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.I don't see "minimal resource usage" being high on the list for this particular purpose.
All code is one.
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Post your Command line tricks
Code: Select all
wget -qO - http://freegeoip.net/xml/$1 | sed '3,12!d;s/<//g;s/>/: /g;s/\/.*//g'
..gnutella..
Re: Post your Command line tricks
Wrong city on mine, but cool! :)
- ivanovnegro
- Minister of Truth
- Posts: 5450
- Joined: Wed Oct 17, 2012 11:12 pm
Re: Post your Command line tricks
Everything was correct.
Re: Post your Command line tricks
Code: Select all
$-> factor
Runs interactive if not provided arguments, or takes a command line argument to break into factors.
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: Post your Command line tricks
Additional: I found out by accident multiple taps of 'alt + .' uses its own little history.machinebacon wrote: Neat one similar to !!:* is pressing "Alt ." or "Esc ."performs aCode: Select all
cd /some/ultra/long/path/to/some.file cp [Alt] + [.] /new/path/
Code: Select all
cp /some/ultra/long/path/to/some.file /new/path/
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.
Re: Post your Command line tricks
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:to get psychedelic band member pictures or whatever. Just keep going till it comes up with something usable... or you get fed up.
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
All code is one.
Re: Post your Command line tricks
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)
<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)