Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In both windows cmd and bash, I'd like to find a way to move the caret by moving the mouse. This would simplify editing the command line for me greatly.

share|improve this question
ctl+a and ctl+e will get you to start and end of line at least on linux terminals... – hbdgaf Dec 31 '10 at 15:19

I'm not aware of any mouse support in bash. For zsh, get zsh mouse support. This gives you cursor mouse movement in X terminals under X on Linux and other unices. It probably works on Windows with Cygwin zsh under unix-like terminals such as Cygwin's native rxvt, Mintty or PuTTYcyg.

share|improve this answer

You could try xdotool for bash.

xdotool getmouselocation 

gives you the mouse location as a coordinate of your screen, you could probably script this to capture mouse motion... and then use

xdotool key

to get the corresponding direction key.

Basically, you can probably write a script to press the left direction key, for example, when the x coordinate of the mouse shifts by a certain number of pixels down. it depends on your screen resolution.

EDIT: This works for me on a horizontal direction. However, you need to think of a way to shut it down if u want it off. Closing the terminal would work.

while true; do horiz=$(xdotool getmouselocation | cut -d" " -f1 | grep -o [0-9]*); if [ ${horiz} -gt ${horiz2} ]; then xdotool key Right; elif [ ${horiz} -lt ${horiz2} ]; then xdotool key Left; fi ; horiz2=$horiz; done &
share|improve this answer
script is partly broken but I like the idea – askonecki May 2 '15 at 12:54

Not many of the newer terminals have mouse support, but I think xterm, rxvt and Eterm do.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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