2

My question is how to get command line completion of commands stored in the history in csh, writing the start of the command and using up/down arrows to move through the list, in a similar way as done in Matlab. Example:

$ vim fi
[press up]
$ vim file.py

I have seen the topic answered for bash shell in the below posts but not for csh. I think that it not may be possible for csh ...

here and here

Thanks

PS: my first incursion into stackoverflow, this site is awesome !!

Community
  • 1
  • 1

2 Answers2

6

I think what you are looking for is one of the following commands:

bindkey -k up history-search-backward

bindkey -k down history-search-forward
Charles Menguy
  • 40,830
  • 17
  • 95
  • 117
Dom
  • 94
  • 1
  • 3
1

Alt+P will perform the functionality in csh. There might be a way to map up arrow key to ALt+P just for csh (not sure if that would mess something else up).

Aside: Alt+/ is a nice shortcut to complete long paths/commands stored in history. For example if you typed this first:

 ls a/very/very/long/path

Then, if you wanted to change your directory into it that just typing the first letter (a) and then Alt+/ would complete the path.

 cd a[Alt+/]
Ashish Uthama
  • 1,331
  • 1
  • 9
  • 14
  • Hi hash blue, thanks for the answer. Alt+P will perform the same function as 'Up' Arrow key but it does not autocomplete the command taking into account the first letters already written there. "Alt+/" is a nice feature which I did not know about thou ! I leave the question open since the problem is still not resolved. – Kiteloopdesign Jan 28 '11 at 09:57
  • @Almendrico: It does for me, i.e if I type 'date' and then 'time' and then d followed by Alt+p, it completes the date call. – Ashish Uthama Jan 28 '11 at 14:14
  • Not exactly as desired...It looks like "Alt+P" iterates through the commands in the same order as shown in the history (use "history" command). Once we have iterated through one command, it is not possible to use "Alt+P" to show it again, or the ones which are below it. Example: type "date", then "time". Then write "da" and press "Alt+P", "date" will appear. Then delete all letters and write "ti"; press "Alt+P". Nothing will occur since we are one step further the history list. You may need to clear the history to see this clearer... Use "history -c" to do it. Rgds – Kiteloopdesign Jan 30 '11 at 15:14
  • By the way, the explained above does not apply to "Alt+/". This trick seems to work independently of the position of the commands within the history. – Kiteloopdesign Jan 30 '11 at 15:19