Navigating the command line
I often write quite long commands into a terminal, something like this
Code:
awk '{print $3}' data.txt | pshistogram -JX15 -R0/6/0/10 -Ba0.5f0.25:"Grain Size (cm)":/a1f0.5:%::."Grain Size Distribution":WeSn -W0.01 -G100/100/100 -L0/50/200 -T0 -Z1 -K -P -Xc -Yc > histogram.ps && gs histogram.ps As I'm testing the command, I need to edit various flags in order to get my graph (in this instance) to look right. My problem is that it takes a while to scroll through the commands letter by letter using the arrow keys. I've discovered that ctrl+a and crtl+e take me to the beginning and end of the line respectively, but I was wondering if there were any commands that can shift me backwards and forwards by one word, much like w, e and b do in vi? Any help gratefully received :) |
Check Bash "bind" builtin values: "bind -p|grep ward-word".
|
I just copy and paste your text and I tried simply
CONTROL+KEY LEFT or RIGHT then it does jump from word to word. Is that what you've been looking for? |
odcheck: If I try ctrl+left or crtl+right, it types D and C (and ctrl+up and ctrl+down gives A and B).
unSpawn: I don't fully understand what you said. I've had a look at the bash manpage, and it seems I need to add something to ~/.inputrc. However, the default shell on these machines is csh, not bash (I'm at university and I don't have root access); sorry, should have mentioned that before. Currently running RHEL4. |
Hi,
Which editor is your bash using? It defaults to emacs (too my knowledge). If it is emacs: Check the emacs docs for key navigation (sorry, cannot tell you which keys. I'm a vi edict :) ). It should also be mentioned in the bash manpage. If you like vi, you can also change your default editor (try set -o vi from the command line and start using vi codes. Hope this helps. |
Thanks druuna. I checked out the csh manpage (since I'm using csh and not bash) and csh defaults to emacs style navigation (but "bindkey can change the key bindings to vi-style bindings en masse" apparently). Running the bindkey command displays all the possible keystroke combinations, some of which I knew (crtl+a, crtl+e), but a whole host of which I didn't. However, I'm still a little confused because I don't understand the syntax of the shortcuts. For example, the commands I'm looking for are these:
Code:
"^[b" -> backward-word edit: having looked around on google a bit, it seems that ^[ is escape. problem solved :) edit 2: just in case anyone needs info on the csh shell and setting keybindings for custom shortcuts, I found this page quite useful http://www.sm.luth.se/~alapaa/file_f...pt/ch30_14.htm I also added this to my ~/.cshrc: Code:
# bindkey functions (ctrl+something = function) |
As you found ^[ is escape, but it can also be typed ctrl+[. There is a third option if the terminal is setup properly: you can type alt+f instead of esc+f.
|
All times are GMT -5. The time now is 05:58 PM. |