Confused by history in tcsh


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Confused by history in tcsh
# 1  
Old 09-08-2009
Question Confused by history in tcsh

I discovered tcsh recently and I am having a very good time with it, except I can't understand how to use the history search features: history-search-backward and i-search-back. To wit:


- history-search-backward (M-p, M-P)
Searches backwards through the history list for a command beginning with the current contents of the input buffer up to the cursor and copies it into the input buffer.

OK, it works, but it only matches lines in the history that BEGIN with whatever I have in the buffer. What if I want to match something in the middle of a past command line? It seems I can achieve that typing *string* then pressing the history-search-backward key, but that is rather annoying. Is there an easier way?


- i-search-back (not bound - but I chose M-q)
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.

OK, it works up to the point when I get the bck: prompt. Then, it seems to search very nicely as long as my buffer is empty. If anything is typed, I have an upper buffer and a lower buffer and I can't seem to make sense of that. Pressing ^W makes the mess even worse. In case my buffer (upper) is not empty, it seems to work just the same, the buffer is just ignored, but my incremental search is appended to the existing buffer. Well, I have absolutely no idea what is going on whenever I try to use that feature. I would be very grateful if someone would take the time to "translate" that mechanism into plain English to me.


- Last, but not least, I keep losing my history! I configured my prompt so it always displays my history line count, I set it to a very high number (999 -- I really like the history in my shell), and every now and then, I log in or just open a new tab in my console application (Yakuake) and the history count has been reset to 1. Why??? Is there some routine in tcsh that discards all the history periodically or could that be some sort of bug? I am using tcsh 6.17.00 by the way. Freshly downloaded and compiled from tcsh.org/MostRecentRelease

Many thanks in advance.
# 2  
Old 09-20-2009
run 'man tcsh' and search for 'history' It will tell you the options and mechanisms.

meanwhile, I always create an alias in my .cshrc:

Code:
alias hist "history|grep $1"

That way I can type 'hist command' and retrieve anything from my history with 'command' in it, in any position.

hth,
dv
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

The Great History of UNIX (1969-1999) | 30 Years of UNIX History | YouTube Video

I am pleased to announce this new video in 1080 HD for UNIX lovers honoring thirty years of UNIX history spanning from 1969 to 1999 presented in 150 seconds (two and a half minutes) in 1080 HD, celebrating the 50th anniversary of UNIX. The Great History of UNIX (1969-1999) | 30 Years of UNIX... (8 Replies)
Discussion started by: Neo
8 Replies

2. UNIX for Dummies Questions & Answers

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (1 Reply)
Discussion started by: sriky86
1 Replies

3. UNIX for Advanced & Expert Users

History to Another file [local user history , but root access]

Hi all, My need is : 1. To know who , when , which command used. 2. Local user should not delete this information. I mean , with an example , i can say i have a user user1 i need to give all the following permissions to user1, : a. A specific directory other than his home... (3 Replies)
Discussion started by: linuxadmin
3 Replies

4. Shell Programming and Scripting

Confused with if/then

Hi All, I'm pretty new to this so please bear with me... I'm trying to write a bash script to first search in a file for a string of characters; if the characters exist than skip the rest of the code until you get to the last line and run that command /sbdin/ldconfig; if the string doesn't... (2 Replies)
Discussion started by: gmdune
2 Replies

5. UNIX for Dummies Questions & Answers

How to review the history and the commands that has been done in this history?

Hello every body, Kindly inform me How Do i find out the time I executed a command previously on UNIX Solaris?? To be more specific and more clear about what i want to know is that I want a command the enables me to know the history and which command i run at this history/time. FYI I used... (5 Replies)
Discussion started by: ahmedamer12
5 Replies

6. UNIX for Advanced & Expert Users

tcsh history for several users

Hi all! I have a nice challange for you today :) I have several users that use "tcsh" the problem is that they all have the same "home_dir" (application reasons...), now... as far as i know (correct me if i'm wrong) every user have an history file in his "home_dir" that calls ".sh_history" or... (0 Replies)
Discussion started by: eliraza6
0 Replies

7. Shell Programming and Scripting

confused with cp

may i know what cp $1 $2 $0 $2 does? (12 Replies)
Discussion started by: C|[anti-trust]
12 Replies
Login or Register to Ask a Question