LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-12-2006, 03:59 AM   #1
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
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
before I put them in a script.

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
 
Old 09-12-2006, 04:21 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Check Bash "bind" builtin values: "bind -p|grep ward-word".
 
Old 09-12-2006, 04:23 AM   #3
odcheck
Member
 
Registered: Aug 2006
Distribution: Fedora, CentOS, RHEL, Debian
Posts: 978

Rep: Reputation: 31
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?
 
Old 09-12-2006, 04:55 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Original Poster
Rep: Reputation: 128Reputation: 128
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.
 
Old 09-12-2006, 05:03 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
Old 09-12-2006, 05:17 AM   #6
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Original Poster
Rep: Reputation: 128Reputation: 128
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
"^[f"          -> forward-word
however, I have no idea what ^[f is in terms of keystrokes. I tried ctrl+[+f, and that didn't work. Can anyone clarify for me?

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)
bindkey ^f forward-word
bindkey ^b backward-word
which makes ctrl+f and ctrl+b move one word forwards and one word backwards respectively.

Last edited by pwc101; 09-12-2006 at 05:43 AM.
 
Old 09-12-2006, 12:08 PM   #7
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
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.
 
  


Reply

Tags
command, csh, keyboard, line, shell, shortcut



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 01:28 PM
Command to display whole filestructure hierarchy f/ command line? mjewell Linux - Newbie 10 01-19-2004 10:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration