LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-26-2017, 10:15 AM   #1
ihowarth
LQ Newbie
 
Registered: Aug 2003
Distribution: Mageia 7.1
Posts: 13

Rep: Reputation: 0
How to edit history substitution in [t]csh


I want to recall an old command line (from within the [t]csh), and then edit it before executing.

What i don't want to do: recall, edit, and execute in one go ('cos i can't remember my complicated command line in sufficient detail to trust a 'blind' edit)

Sure, i could just use the up-arrow key and trawl through a million old lines looking for the right one -- but oops, my attention wandered and i missed the line i wanted.

So what i really want is something *like*:
!man : p
(sorry, had to put in some spacing to stop getting an unwanted emoji!), but with the recalled line actually as the command line, waiting for my edit (and not just printed out and returned to the prompt, which is what the above invocation does). I can't see how to do this from the man page, or the threads...but i think i'm probably just missing something obvious....?

Thanks
ian
 
Old 04-26-2017, 02:09 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
I don't use tcsh but it looks like "i-search-back" will do what you want.

From the tcsh man page:
Quote:
i-search-back (not bound)
Searches backward like history-search-backward, copies the first match into the input buffer with the cursor positioned at the end of the pattern, and prompts with `bck: ' and the first match. Additional characters may be typed to extend the search, i-search-back may be typed to continue searching with the same pattern, wrapping around the history list if necessary, ( i-search-back must be bound to a single character for this to work) or one of the following special characters may be typed:

^W
Appends the rest of the word under the cursor to the search pattern.
delete (or any character bound to backward-delete-char)
Undoes the effect of the last character typed and deletes a character from the search pattern if appropriate.

^G
If the previous search was successful, aborts the entire search. If not, goes back to the last successful search.

escape
Ends the search, leaving the current line in the input buffer.
Note that it is not bound to a key. You could bind it to ctrl+R which is backward search in bash.
Code:
bindkey '^R' i-search-back
 
1 members found this post helpful.
Old 04-26-2017, 04:13 PM   #3
ihowarth
LQ Newbie
 
Registered: Aug 2003
Distribution: Mageia 7.1
Posts: 13

Original Poster
Rep: Reputation: 0
Ah, very helpful pointer....actually, "history-search-backwards" is pretty much what i wanted, i was just looking in the wrong place in the man pages. Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to edit history to remove few commands executed g_ramesh Linux - Newbie 14 06-03-2015 03:42 AM
[SOLVED] History utility error in Linux Mint 14; cannot delete history mintyninja41 Linux - Newbie 3 03-22-2013 07:36 AM
LXer: HISTORY Those that fail to learn from history are doomed to repeat it LXer Syndicated Linux News 0 04-11-2012 04:11 PM
How to edit/decrease browser history? buccaneere Linux - General 5 09-27-2009 05:19 PM
tcsh: can you save the history from multiple shells to one history file? BrianK General 2 04-23-2009 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration