Using read and by typing `word followed by the left arrow , one get

 $ read

The same goes for the Home and End keys that lead to ^[[H and ^[[F respectively.

How can I handle those characters, so that I go backward with the left arrow `, at the beginning and end of what has been written with Home and End respectively.


readline library usually handles this, and inputrc tells you which codes are emitted. Forcing the shell into interactive mode should enable these features. curses is a library that does the full support for moving the cursor around (if you want a text editor or something).

But ultimately, you have to remember, that the terminal is the sender and receiver of input/output. So... printing a control sequence that moves the cursor should move the cursor, so you can always write anything to any position on the screen. Terminals differ somewhat in control sequences they respond to, but check out this for the reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.