View previous topic :: View next topic |
Author |
Message |
/dev/random l33t
Joined: 26 Nov 2004 Posts: 704 Location: Austin, Texas, USA
|
Posted: Sun Dec 09, 2007 11:00 pm Post subject: Re: Share you totally awesome shell tips |
|
|
PraetorZero wrote: | melange wrote: | Do as the topic says, share your tips and great ideas
It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner" |
What does yes do? Just do a Y and carriage return? |
It prints a string repeatedly until you kill it with ^C.
# yes foo
Would print foo to the screen until you kill it. |
|
Back to top |
|
|
mdeininger Veteran
Joined: 15 Jun 2005 Posts: 1740 Location: Emerald Isles, observing Dublin's docklands
|
Posted: Sun Dec 09, 2007 11:00 pm Post subject: Re: Share you totally awesome shell tips |
|
|
PraetorZero wrote: | melange wrote: | Do as the topic says, share your tips and great ideas
It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner" |
What does yes do? Just do a Y and carriage return? |
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
^C _________________ "Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland
( Twitter | Blog | GitHub ) |
|
Back to top |
|
|
melange Tux's lil' helper
Joined: 16 Sep 2004 Posts: 110
|
Posted: Sun Dec 09, 2007 11:02 pm Post subject: Re: Share you totally awesome shell tips |
|
|
PraetorZero wrote: | melange wrote: | Do as the topic says, share your tips and great ideas
It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner" |
What does yes do? Just do a Y and carriage return? |
actually it's not *totally* useless assume you have an app which asks a lot of y/N questions and you just want to say yes to all of them. Then you just do:
|
|
Back to top |
|
|
arcanex n00b
Joined: 10 Jun 2007 Posts: 1
|
Posted: Sun Dec 09, 2007 11:39 pm Post subject: |
|
|
Convenient if you open and close the terminal a lot. Then, if you want to launch an X app without keeping the terminal open, you can just append '&q' to the end of the command.
Turns on vi mode in bash. Pretty much required if you like vi. Especially useful is the '/' command to search your command history.
If you like vi, you might like this script I use as my XClipboard manager (requires xclip):
Code: |
#!/bin/sh
VI="vim -n"
XCLIP=/home/paulo/bin/xclip
TMPFILE=/tmp/viclip.${RANDOM}.tmp
${XCLIP} -o > ${TMPFILE}
until [ "$I" == "q" ]
do
${VI} ${TMPFILE}
${XCLIP} < ${TMPFILE}
clear
${XCLIP} -o
echo ""
echo "===[Type 'q' to quit, 'p' to re-paste, any other key to re-edit]==="
read I
while [ "$I" == "p" ]
do
${XCLIP} < ${TMPFILE}
echo "==[repasted]=="
read I
done
done
rm ${TMPFILE}
|
Then I bind a key to launch this script (viclip.sh). It opens up vi with the current XClipboard content, allows you to edit it, then keeps the xterm open so that you don't lose it (which is really easy), and also allows you to re-paste (to the XClipboard) or re-edit. I also like to use it as an all-purpose temporary text file editor; I wrote this post in 'viclip.sh', for example, then pasted it to the Firefox text box.
Also, instead of Ctrl-s and Ctrl-q, I prefer Ctrl-z. It halts the program execution entirely, and that's usually what I want to do (when compiling, for example.) Then I can just 'fg' back if and when I want to. |
|
Back to top |
|
|
papal_authority Veteran
Joined: 31 Mar 2004 Posts: 1823 Location: Canada
|
Posted: Sun Dec 09, 2007 11:57 pm Post subject: |
|
|
mdeininger wrote: | it's a terminal function... works on "real" virtual terminals on tty1 and the like, and on virtual terminals like xterm... at least those're the only ones i tried it on. |
Yah, it's software flow control (i.e. XON/XOFF), I generally only use it when I'm on an actual hardwired terminal. Once you have a mouse, multiple sessions, and cut n' paste, it really isn't all that useful IMHO. To each their own though _________________ The free market gave me gonorrhea. |
|
Back to top |
|
|
mdeininger Veteran
Joined: 15 Jun 2005 Posts: 1740 Location: Emerald Isles, observing Dublin's docklands
|
Posted: Mon Dec 10, 2007 12:04 am Post subject: |
|
|
papal_authority wrote: | mdeininger wrote: | it's a terminal function... works on "real" virtual terminals on tty1 and the like, and on virtual terminals like xterm... at least those're the only ones i tried it on. |
Yah, it's software flow control (i.e. XON/XOFF), I generally only use it when I'm on an actual hardwired terminal. Once you have a mouse, multiple sessions, and cut n' paste, it really isn't all that useful IMHO. To each their own though | kinda depends... when you're compiling something big or you're debugging something with a lot of logfile output, and your terminal's scrollback buffer is a bit short, ctrl+s is pretty handy .
it's handy to know either way; it also seems to be one of those lesser-known bits, and it's somewhat console-related, so i figured i'd throw it in =) _________________ "Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland
( Twitter | Blog | GitHub ) |
|
Back to top |
|
|
poly_poly-man Advocate
Joined: 06 Dec 2006 Posts: 2477 Location: RIT, NY, US
|
Posted: Mon Dec 10, 2007 12:51 am Post subject: |
|
|
^d is your friend
Also, shift Page up/down is good, and (ctrl-)alt-Fx
also, the best command ever:
telnet polypmanports.hopto.org
poly-p man _________________ iVBORw0KGgoAAAANSUhEUgAAA
avatar: new version of logo - see topic 838248. Potentially still a WiP. |
|
Back to top |
|
|
denstark l33t
Joined: 02 Jun 2003 Posts: 654 Location: sd.ca.us
|
Posted: Mon Dec 10, 2007 1:06 am Post subject: |
|
|
poly_poly-man wrote: | ^d is your friend
Also, shift Page up/down is good, and (ctrl-)alt-Fx
also, the best command ever:
telnet polypmanports.hopto.org
poly-p man |
that wasn't a plug at ALL. _________________ Blog
Code: | denstark> starbuck authorizes torture?
rokstar> sure they do, you tried their coffee?
|
|
|
Back to top |
|
|
poly_poly-man Advocate
Joined: 06 Dec 2006 Posts: 2477 Location: RIT, NY, US
|
Posted: Mon Dec 10, 2007 1:10 am Post subject: |
|
|
denstark wrote: | poly_poly-man wrote: | ^d is your friend
Also, shift Page up/down is good, and (ctrl-)alt-Fx
also, the best command ever:
telnet polypmanports.hopto.org
poly-p man |
that wasn't a plug at ALL. |
Just a simple command that works on many systems
poly-p man _________________ iVBORw0KGgoAAAANSUhEUgAAA
avatar: new version of logo - see topic 838248. Potentially still a WiP. |
|
Back to top |
|
|
Bones McCracker Veteran
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Mon Dec 10, 2007 1:10 am Post subject: |
|
|
Repeat the last command, replacing string1 with string2
By the way, there's a thread in the Tips & Tricks forum on the exact same topic that has accumulated five years worth of tips:
https://forums.gentoo.org/viewtopic-t-15443-highlight-shell.html _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
Last edited by Bones McCracker on Mon Dec 10, 2007 1:45 am; edited 2 times in total |
|
Back to top |
|
|
Etal Veteran
Joined: 15 Jul 2005 Posts: 1931
|
Posted: Mon Dec 10, 2007 1:16 am Post subject: |
|
|
mdeininger wrote: | papal_authority wrote: | mdeininger wrote: | it's a terminal function... works on "real" virtual terminals on tty1 and the like, and on virtual terminals like xterm... at least those're the only ones i tried it on. |
Yah, it's software flow control (i.e. XON/XOFF), I generally only use it when I'm on an actual hardwired terminal. Once you have a mouse, multiple sessions, and cut n' paste, it really isn't all that useful IMHO. To each their own though | kinda depends... when you're compiling something big or you're debugging something with a lot of logfile output, and your terminal's scrollback buffer is a bit short, ctrl+s is pretty handy .
it's handy to know either way; it also seems to be one of those lesser-known bits, and it's somewhat console-related, so i figured i'd throw it in =) |
I prefer ScrollLock _________________ “And even in authoritarian countries, information networks are helping people discover new facts and making governments more accountable.”– Hillary Clinton, Jan. 21, 2010 |
|
Back to top |
|
|
Bones McCracker Veteran
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Mon Dec 10, 2007 2:09 am Post subject: |
|
|
More of a console tip than a shell tip:
Command history incremental search (as a key combo).
1. Type first few chars of some command in your history you'd like to repeat
2. press 'Meta+PgUp'
This retrieves the most recent matching command (right one? hit return to execute; not right? press it again and incremental search continues).
The modifier key varies depending on how your /etc/inputrc is set up and what you are using (tty, gnome-terminal, konsole, etc.)
I have found this to be very handy. You'll be surprised how much of your terminal work is the same commands used over and over. There are other related key combinations (explore inputrc and man bash), but that's the one I've found the most useful. _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
|
|
Back to top |
|
|
bunder Bodhisattva
Joined: 10 Apr 2004 Posts: 5934
|
Posted: Mon Dec 10, 2007 4:12 am Post subject: |
|
|
merged. _________________
Neddyseagoon wrote: | The problem with leaving is that you can only do it once and it reduces your influence. |
banned from #gentoo since sept 2017 |
|
Back to top |
|
|
bunder Bodhisattva
Joined: 10 Apr 2004 Posts: 5934
|
Posted: Mon Dec 10, 2007 4:14 am Post subject: |
|
|
want to look for bots who tried logging into your ssh/ftp servers in the past day?
Code: | grep "`date +'%b %e'`" /var/log/auth.log | grep "Invalid user"
grep "`date +'%b %e'`" /var/log/vsftpd.log | grep "FAIL LOGIN"
|
works great in cron. _________________
Neddyseagoon wrote: | The problem with leaving is that you can only do it once and it reduces your influence. |
banned from #gentoo since sept 2017 |
|
Back to top |
|
|
JeliJami Veteran
Joined: 17 Jan 2006 Posts: 1086 Location: Belgium
|
Posted: Mon Dec 10, 2007 3:07 pm Post subject: |
|
|
BoneKracker wrote: | More of a console tip than a shell tip:
Command history incremental search (as a key combo).
1. Type first few chars of some command in your history you'd like to repeat
2. press 'Meta+PgUp'
This retrieves the most recent matching command (right one? hit return to execute; not right? press it again and incremental search continues).
|
Cool, but I like Ctl-R better
1. Type Ctl-R (prompt changes)
2. Type some chars of a former command (does not need to be the first ones)
3. Use backspace to correct errors _________________ Unanswered Post Initiative | Search | FAQ
Former username: davjel |
|
Back to top |
|
|
Bones McCracker Veteran
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Mon Dec 10, 2007 5:23 pm Post subject: |
|
|
davjel wrote: | BoneKracker wrote: | More of a console tip than a shell tip:
Command history incremental search (as a key combo).
1. Type first few chars of some command in your history you'd like to repeat
2. press 'Meta+PgUp'
This retrieves the most recent matching command (right one? hit return to execute; not right? press it again and incremental search continues).
|
Cool, but I like Ctl-R better
1. Type Ctl-R (prompt changes)
2. Type some chars of a former command (does not need to be the first ones)
3. Use backspace to correct errors |
Cool. I didn't know about that. I like that better too! _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
|
|
Back to top |
|
|
swimmer Veteran
Joined: 15 Jul 2002 Posts: 1330 Location: Netherlands
|
Posted: Mon Dec 10, 2007 10:44 pm Post subject: |
|
|
Hmm - is this shell-dependent? If I use Ctrl-R in zsh nothing happens ...
Greetz
swimmer |
|
Back to top |
|
|
JeliJami Veteran
Joined: 17 Jan 2006 Posts: 1086 Location: Belgium
|
Posted: Tue Dec 11, 2007 8:29 am Post subject: |
|
|
swimmer wrote: | Hmm - is this shell-dependent? If I use Ctrl-R in zsh nothing happens ... |
/me using bash _________________ Unanswered Post Initiative | Search | FAQ
Former username: davjel |
|
Back to top |
|
|
Bones McCracker Veteran
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Tue Dec 11, 2007 7:04 pm Post subject: |
|
|
zsh must have command history incremental search -- it's probably a different key binding or something. Look at info zsh or something. On bash these sorts of things are set up in inputrc. _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
|
|
Back to top |
|
|
swimmer Veteran
Joined: 15 Jul 2002 Posts: 1330 Location: Netherlands
|
Posted: Tue Dec 11, 2007 11:00 pm Post subject: |
|
|
Hmm - 'pinfo zsh' mentions indeed Ctrl-R for incremental history search backwards but using this keybinding nothing happens whereas it works as designed in bash :-/
But hey - I started using zsh recently and am still an absolut n00b in his usage
Thanks anyway
swimmer |
|
Back to top |
|
|
Bones McCracker Veteran
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
Posted: Tue Dec 11, 2007 11:51 pm Post subject: |
|
|
I really hate to say it, but .... you could always, uh ... RTFM. _________________
patrix_neo wrote: | The human thought: I cannot win.
The ratbrain in me : I can only go forward and that's it. |
|
|
Back to top |
|
|
Ox- Guru
Joined: 19 Jun 2003 Posts: 305
|
Posted: Wed Dec 12, 2007 4:47 pm Post subject: |
|
|
swimmer wrote: | Hmm - 'pinfo zsh' mentions indeed Ctrl-R for incremental history search backwards but using this keybinding nothing happens whereas it works as designed in bash :-/
But hey - I started using zsh recently and am still an absolut n00b in his usage
Thanks anyway
swimmer | Going off the top of my head here so I could be wrong, but ctrl-R for history search is usually the key binding in "emacs mode". If you shell editing mode is something else like vi then binding will be different. It's been 16-years since I last used zsh and it's not installed on my box so I can't look up the stuff in zsh.1 for you |
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Thu Dec 13, 2007 12:30 am Post subject: |
|
|
duh! Code: | echo "bindkey \"^R\" history-incremental-search-backward
bindkey \"^S\" history-incremental-search-forward" >> .zshrc
. .zshrc |
_________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
Bones McCracker Veteran
Joined: 14 Mar 2006 Posts: 1611 Location: U.S.A.
|
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Thu Dec 13, 2007 3:31 am Post subject: |
|
|
eww! Who reads all that _________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
|