Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
2  
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

3 Answers 3

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

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

share|improve this answer

Your Answer

 
discard

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.