Re: find a command i have recently used in bash
On Sat, Feb 01, 2003 at 12:25:31AM +0100, Carel Fellinger wrote: On Fri, Jan 31, 2003 at 03:09:54PM +0100, Ulf Rompe wrote: ... As an example, another useful (for me) addition to the inputrc is this one: # Ctrl-Left/Right jumps wordwise on cmd line \e[D: backward-word \e[C: forward-word I fail to see the Control part here, it just looks like the codes for right and left. I would be very interested if it could work with control/meta, would make it easier for me to remember all the search commands. it's different on my keyboard, too. see below. This redefines the commands normally known as M-b / M-f to more intuitive key strokes. I must be missing something:) Aren't those already bound to word movement? Besides, the above inputrc snippet doesn't touch M-b/M-f, but the cursor keys. on my keyboard it's ESC-f forward and ESC-b backward which i don't like. seems klutzy. ctl-arrow would be much more sexful. try this: press ctl-v press leftarrow voila, there's your key sequence for left-arrow. now try it again, with a variation: press ctl-v press CTL-leftarrow [holding control down] is that the same as it was without control? it wasn't on my setup. it's different for each modifier and for each combination of modifiers! here's the results of my own tests -- your setup may be different: # leftarrow shift alt ctl # ^[[D- - - # ^[[2D+shift- - # ^[[3D - +alt - # ^[[4D+shift +alt - # ^[[5D - - +ctl # ^[[6D+shift- +ctl # ^[[7D - +alt+ctl # ^[[8D+shift +alt+ctl # # uparrow= ^[[A -- ^[[8A # downarrow = ^[[B -- ^[[8B # rightarrow = ^[[C -- ^[[8C also learn about page-up -down, home, end, insert and delete. very cool. -- I use Debian/GNU Linux version 3.0; Linux server 2.4.20-k6 #1 Mon Jan 13 23:49:14 EST 2003 i586 unknown DEBIAN NEWBIE TIP #101 from Joost Kooij [EMAIL PROTECTED] : Looking for a way to CREATE A PAGE OF LINKS to all the */index.html that already exist in your /usr/share/doc tree? apt-get install dwww then point your browser to: http://localhost/dwww Also see http://newbieDoc.sourceForge.net/ ... -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Thu, Jan 30, 2003 at 07:48:14AM +0800, [EMAIL PROTECTED] wrote: On 29 Jan 2003 15:54:32 -0600, Ron Johnson wrote: On Wed, 2003-01-29 at 10:28, Nathan E Norman wrote: On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? tcsh has a far more elegant (tm) approach to the problem. Typing lsALT-P (or META-P) will get you only all the commands that begin with ls (eliminating such oddities as echo lst.txt). If somebody knows the precise bash equivalent of this, let me know. BTW AFAICT the tcsh equivalent of CTRL-R is a wildcard sequence like *ls*, which will capture all *ls* whether command or argument. well, thanx for suggestion. but i am not using tcsh and control r served my purpose well so wont be shifting to it either! but i read up on tcsh in aptitude and it seems interesting. -- regards, sandip p deshmukh --*** A diplomat is man who always remembers a woman's birthday but never her age. -- Robert Frost -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
[EMAIL PROTECTED] writes: tcsh has a far more elegant (tm) approach to the problem. Typing lsALT-P (or META-P) will get you only all the commands that begin with ls (eliminating such oddities as echo lst.txt). If somebody knows the precise bash equivalent of this, let me know. As I wrote yesterday you can define keys for history-search-backward and history-search-forward. A good placement for these commands are the PgUp/PgDown keys since M-p is already defined per default. Put this into your /etc/inputrc or ~/.inputrc : # PgUp/Down searches history in bash \e[5~:history-search-backward \e[6~:history-search-forward If you really want M-p a the key to search bachward, you would have to write this: \ep: history-search-backward For a list of available readline commands look into the bash manpage. To see what a key combination ends up as, type C-v (that's Ctrl V) followed by the key combination. Just translate a leading ^[ of your key combinations into \e in your inputrc. As an example, another useful (for me) addition to the inputrc is this one: # Ctrl-Left/Right jumps wordwise on cmd line \e[D: backward-word \e[C: forward-word This redefines the commands normally known as M-b / M-f to more intuitive key strokes. [x] ulf -- A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station... -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On 29 Jan 2003 15:54:32 -0600, Ron Johnson wrote: On Wed, 2003-01-29 at 10:28, Nathan E Norman wrote: On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? If you're using bash, and the command you want to retrieve was typed in the last 500 or so commands, try ctrl-r ls which should recall the most recent command with the string ls in it. You can also use the history command to view your history. Any command in your history can be reused by prefixing its history number with a bang ('!'). Thus if history says 422 ls -lAF /usr/local you can type !422 at a prompt to issue that command again. history + grep can be fun. I find this a helpful refinement: $ history | sort -rn | less tcsh has a far more elegant (tm) approach to the problem. Typing lsALT-P (or META-P) will get you only all the commands that begin with ls (eliminating such oddities as echo lst.txt). If somebody knows the precise bash equivalent of this, let me know. BTW AFAICT the tcsh equivalent of CTRL-R is a wildcard sequence like *ls*, which will capture all *ls* whether command or argument. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
find a command i have recently used in bash
hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? -- regards, sandip p deshmukh --*** BOFH excuse #40: not enough memory, go get system upgrade -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, 29 Jan 2003, Sandip P Deshmukh wrote: now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? well, if nothing else, you can hit up a few times and it'll scroll through your command history. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? You can press ctrl-r to search backwards in your history or you can use csh-like history expansion with ! (read the HISTORY EXPANSION section in the bash man page) Stephen Rüger -- Jede Nation spottet über die andere, und alle haben recht. -- Schopenhauer msg27173/pgp0.pgp Description: PGP signature
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? Somebody else posted the same thing today. The answer is to hit Ctrl-R then 'ls', and repeat Ctrl-R as necessary. -- Colin Watson [[EMAIL PROTECTED]] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? If you're using bash, and the command you want to retrieve was typed in the last 500 or so commands, try ctrl-r ls which should recall the most recent command with the string ls in it. You can also use the history command to view your history. Any command in your history can be reused by prefixing its history number with a bang ('!'). Thus if history says 422 ls -lAF /usr/local you can type !422 at a prompt to issue that command again. history + grep can be fun. Finally, (and perhaps most obvious) you can use ctrl-p and ctrl-n to cycle backwards and forwards through your command history. For most terminal types these sequences are mapped to the up-arrow and down-arrow respectively. -- Nathan Norman - Incanus Networking mailto:[EMAIL PROTECTED] People demand freedom of speech to make up for the freedom of thought which they avoid. -- Soren Aabye Kierkegaard -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
-- Sandip P Deshmukh [EMAIL PROTECTED] wrote (on Wednesday, 29 January 2003, 07:51 PM +0530): i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? I don't know about that, but if you hit your up-arrow, it will scroll backwards through the command history -- I do this a lot to save on keystrokes. (Note: Hitting down-arrow will then take you forward through the history, but only after you've gone backwards.) -- Matthew Weier O'Phinney [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
Sure - to complete the prior command beginning with ls, do: !ls which will re-execute the last comment beginning with ls. If you need finer-grained history, use the command: history which will let you copy-and-paste a prior command. ap -- Andrew J Perrin - http://www.unc.edu/~aperrin Assistant Professor of Sociology, U of North Carolina, Chapel Hill [EMAIL PROTECTED] * andrew_perrin (at) unc.edu On Wed, 29 Jan 2003, Mike Dresser wrote: On Wed, 29 Jan 2003, Sandip P Deshmukh wrote: now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? well, if nothing else, you can hit up a few times and it'll scroll through your command history. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
RE: find a command i have recently used in bash
let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? -- regards, sandip p deshmukh IIRC, you can type history | less (minus quotes) to get the list of commands you've already typed, then if the past command was number 50 (for example), you can say !50 to re-execute that command, or to execute the last command typed use !! (but the up/down arrow is faster for the most recent commands IMO). man history should give you all the nitty gritty details of how to use history buffer. Good luck Drew Cohan drew_at_drewcohan_dot_com -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wednesday 29 January 2003 08:21 am, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? -- regards, sandip p deshmukh --*** BOFH excuse #40: not enough memory, go get system upgrade you can use the up arrow to reach previous commands. or you can grep your .bash_history, like grep ls ~/.bash_history -jason pepas -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wednesday 29 January 2003 15:21, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? The same has already been asked today in the thread scrolling trough the argument of a command See my reply there whether it is of any help for you. HTH, Michael -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
RE: find a command i have recently used in bash
Try CTRL + r then ls Then optionnally retype CTRL R as many times as needed to reach the expression you are actually searching. Vincent -Original Message- From: Mike Dresser [mailto:[EMAIL PROTECTED]] Sent: Wednesday 29 January 2003 16:30 To: [EMAIL PROTECTED] Subject: Re: find a command i have recently used in bash On Wed, 29 Jan 2003, Sandip P Deshmukh wrote: now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? well, if nothing else, you can hit up a few times and it'll scroll through your command history. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? Type ^R (Control R) at the Bash prompt and then type first few characters of the command you want to recall. Bash will complete the rest of the command line as soon as it can uniquely determine the string from command history. regards, -- Amal Phadke, Ph.D. email: phadke at hydrodyn.org -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
Hi, maybe what you are looking for is: !first_letter_of_the_command i.e.: in the case of ls -l, if you use !l, it will repeat the last used command that started with the letter l. Rod On Wed, 29 Jan 2003, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: [find a command in shell history] Another way is to use the 'history' command (and pipe it through grep). -D -- Whoever loves discipline loves knowledge, but he who hates correction is stupid. Proverbs 12:1 http://dman.ddts.net/~dman/ msg27221/pgp0.pgp Description: PGP signature
Re: find a command i have recently used in bash
On Wed, 29 Jan 2003 16:30:54 +0100 Stephen Rueger [EMAIL PROTECTED] wrote: On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. Ahoj! maybe you can try '!smth' it's mean last command started on 'smth' you can combine this with * Best regards - olaf vel ender -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, 2003-01-29 at 10:28, Nathan E Norman wrote: On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: hello all i am sure there must be a way of doing it. i am not getting it though. let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? If you're using bash, and the command you want to retrieve was typed in the last 500 or so commands, try ctrl-r ls which should recall the most recent command with the string ls in it. You can also use the history command to view your history. Any command in your history can be reused by prefixing its history number with a bang ('!'). Thus if history says 422 ls -lAF /usr/local you can type !422 at a prompt to issue that command again. history + grep can be fun. I find this a helpful refinement: $ history | sort -rn | less -- +---+ | Ron Johnson, Jr.mailto:[EMAIL PROTECTED] | | Jefferson, LA USA http://members.cox.net/ron.l.johnson | | | | Fear the Penguin!! | +---+ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
* Jason Pepas ([EMAIL PROTECTED]) [030129 10:33]: On Wednesday 29 January 2003 08:21 am, Sandip P Deshmukh wrote: let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? you can use the up arrow to reach previous commands. or you can grep your .bash_history, like grep ls ~/.bash_history The .bash_history is only written when bash is exiting, so it won't include commands you recently typed within the same session. That is to say, it won't have anything since you most recently logged in. It's also prone to missing some commands from previous sessions as well, in cases in which you had multiple sessions running concurrently. This is because bash reads ~/.bash_history when starting up, works with the history in memory, then writes ~/.bash_history when exiting. So let's say you're working in a few xterms. You start one, and go like this: ls cd ~/foo cat bar Then you start another xterm, with another bash, and do: vi asdf.txt cat aoeu.txt exit Then you go back and close the first xterm. your .bash_history file will not have the lines vi asdf.txt or cat aoeu.txt in it. There are some shell options to change the precise bahavior of the shell, but I believe I have illustrated the default behavior here. I think the best way to do what OP asked is control-R. man readline to learn more about how your command line is way more powerful than probably you previously imagined. good times, Vineet -- http://www.doorstop.net/ -- One nation, indivisible, with equality, liberty, and justice for all. msg27303/pgp0.pgp Description: PGP signature
Re: find a command i have recently used in bash
The .bash_history is only written when bash is exiting, so it won't include commands you recently typed within the same session. That is to say, it won't have anything since you most recently logged in. It's also prone to missing some commands from previous sessions as well, in cases in which you had multiple sessions running concurrently. This is because bash reads ~/.bash_history when starting up, works with the history in memory, then writes ~/.bash_history when exiting. thanks. I had noticed odd behavior regarding bash_history before, now I know why. -jason pepas -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 04:30:54PM +0100, Stephen Rueger wrote: On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? You can press ctrl-r to search backwards in your history or you can use thanx. this is perfect. just what i wanted csh-like history expansion with ! (read the HISTORY EXPANSION section in the bash man page) this is a bit tricky. lets say, it executes an unwanted delete command in a hurry! -- regards, sandip p deshmukh --*** We are experiencing system trouble -- do not adjust your terminal. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 10:28:11AM -0600, Nathan E Norman wrote: On Wed, Jan 29, 2003 at 07:51:07PM +0530, Sandip P Deshmukh wrote: let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? You can also use the history command to view your history. Any command in your history can be reused by prefixing its history number with a bang ('!'). Thus if history says 422 ls -lAF /usr/local you can type !422 at a prompt to issue that command again. history + grep can be fun. oh sure. this is also very useful. Finally, (and perhaps most obvious) you can use ctrl-p and ctrl-n to cycle backwards and forwards through your command history. For most terminal types these sequences are mapped to the up-arrow and down-arrow respectively. sure i was doing this already. but it is only : sequential browsing. does not help if the command you are looking for is 200 commands back! -- regards, sandip p deshmukh --*** It seems a little silly now, but this country was founded as a protest against taxation. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: find a command i have recently used in bash
On Wed, Jan 29, 2003 at 11:31:54AM -0500, Matthew Weier O'Phinney wrote: -- Sandip P Deshmukh [EMAIL PROTECTED] wrote (on Wednesday, 29 January 2003, 07:51 PM +0530): let us say, i have done ls -l , etc etc then i have done a few more commands at the prompt. now, i want to use that ls command again. is there a way inwhich i can reach it quickly? for instance, i type ls and some other key and bash completes from history? I don't know about that, but if you hit your up-arrow, it will scroll backwards through the command history -- I do this a lot to save on keystrokes. i will recommend control r for you. very useful! try it, harness the power ;) -- regards, sandip p deshmukh --*** In a whiskey it's age, in a cigarette it's taste and in a sports car it's impossible. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]