tags:

views:

45

answers:

1

I am writing my own shell and need to implement a history feature where up and down arrow keys show history of commands executed. I need to find out when up and down keys are pressed.

How do i do this?

+1  A: 

you want to be capturing input in raw mode. this can get kinda complicated, but here's an example that should get you on the right path:

http://docs.linux.cz/programming/c/unix%5Fexamples/raw.html

i'm assuming you're writing your shell in c. if you're using a more high-level language, there might be an easy way to get raw input. in python, for instance, i would use the ncurses module.

Igor
Of course, there's nothing in particular preventing him from using ncurses from C.
Michiel Buddingh'