Re: [SLUG] Re: useful bash tricks thread

2009-02-08 Thread Amos Shapira
At the risk of being called an oldie, I keep using !-notation since
the early tcsh days. E.g. !$ or !:2-3.

You can also use things like

!less:*

to fetch the parameters of the latest less command.

I can't type alt- because alt-shift is my keyboard language-switching
combination, so I don't know how this compares with good old
bang-notation.

Other useful stuff:

^x^y will replace the first x on the previous line by y. Use a
third ^ after y if it contains space. It's actually a short for
!!:s/x/y/

Where !!:s comes handy is to replace globally: !!gs/x/y/ will replace
ALL of the x's on last line by y's.

Then again - you can type !command or !-3 to use another history
line as a basis.

And one last thing, related to security - if you type a sensitive
string on the command line and get it into your history, use history
-d to delete this line.

Cheers,

--Amos
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Re: useful bash tricks thread

2009-02-08 Thread Owen Townend
2009/2/9 Amos Shapira amos.shap...@gmail.com:
[snip]

 And one last thing, related to security - if you type a sensitive
 string on the command line and get it into your history, use history
 -d to delete this line.


There is an easier way around this. Most shells, bash included will
exclude a line from the history if you begin it with a space.

cheers,
Owen.
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Re: useful bash tricks thread

2009-02-08 Thread Rick Welykochy

Owen Townend wrote:

2009/2/9 Amos Shapira amos.shap...@gmail.com:
[snip]

And one last thing, related to security - if you type a sensitive
string on the command line and get it into your history, use history
-d to delete this line.



There is an easier way around this. Most shells, bash included will
exclude a line from the history if you begin it with a space.


My bash doesn't do this. It includes the line in the history :(

but

HISTSIZE=2000
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor

might have an effect on this behaviour.

cheer
rickw



--
_
Rick Welykochy || Praxis Services

If you have any trouble sounding condescending, find a Unix user to show
you how it's done.
 -- Scott Adams
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Re: useful bash tricks thread

2009-02-08 Thread Daniel Bush
2009/2/9 Amos Shapira amos.shap...@gmail.com

 At the risk of being called an oldie, I keep using !-notation since
 the early tcsh days. E.g. !$ or !:2-3.

 You can also use things like

 !less:*

 to fetch the parameters of the latest less command.

 I can't type alt- because alt-shift is my keyboard language-switching
 combination, so I don't know how this compares with good old
 bang-notation.

 Other useful stuff:

 ^x^y will replace the first x on the previous line by y. Use a
 third ^ after y if it contains space. It's actually a short for
 !!:s/x/y/

 ...


I knew it.  I knew there were more of you out there! :)
That whole bang/caret substitute-a-pattern-and-then-run thing just scares me
though, plus its hard to type.  I'll stick with ctrl-r and vi-mode.  But
interesting...





-- 
Daniel Bush
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Re: useful bash tricks thread

2009-02-08 Thread Owen Townend
2009/2/9 Rick Welykochy r...@praxis.com.au:
 Owen Townend wrote:

 2009/2/9 Amos Shapira amos.shap...@gmail.com:
 [snip]

 And one last thing, related to security - if you type a sensitive
 string on the command line and get it into your history, use history
 -d to delete this line.


 There is an easier way around this. Most shells, bash included will
 exclude a line from the history if you begin it with a space.

 My bash doesn't do this. It includes the line in the history :(

 but

 HISTSIZE=2000
 SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor

 might have an effect on this behaviour.

Ah, my default bashrc has HISTCONTROL set.

~$ echo $HISTCONTROL
ignoreboth

This sets ignorespace and ignoredups, see the man page for details.

cheers,
Owen.
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Re: useful bash tricks thread

2009-02-07 Thread Tony Sceats
On Sat, Feb 7, 2009 at 11:58 PM, Daniel Bush dlb.id...@gmail.com wrote:



 On Feb 6, 9:06 pm, Tony Sceats t...@fatuous.org wrote:
  It's been a while since there's been a thread like this, so I thought it
  would be fun :)
 
  so, have you got any?
 
  I've got 2 to share today:
 
  alt and then
  alt 
 

 woo, that's kinda interesting.
 It seems to pick the last word for each entry in the command-line
 history?


yep, kinda like !$, but this is an interactive search on the last argument
to previous commands, instead of just static 'last argument to last command'
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html