editing bash command line with vi

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers editing bash command line with vi
# 1  
Old 09-03-2002
editing bash command line with vi

Is there a way using bash that I can edit a command line using vi.

I.e. if I have a long command line and I want to edit it.....by typing vi and then having the command open in an editing window....

I beleive this can be done in k shell by pressing v....however can find out how this can be done in bash.
# 2  
Old 09-03-2002

is it really needed

why not use the vi first.

i mean to say that you can write the command in a file using the vi editor and then execute it

i just tried this also which may sound a bit funny

alias "exec=vi /tmp/file;sh /tmp/junk"

now when you say exec, it would open a file, you can write your command in that and when you save and exit, it would execute that same file.
# 3  
Old 09-03-2002
Cheers... although not what I'm after.... I'm comfortable with editing the command line (esp with bash using the arrow keys and ctrl+a and crtl+e)....but was just curious if there is a way to do what I have asked. I'm really not after a work around as I know plenty....just adding some artillery to my skills really.

# 4  
Old 09-03-2002
You should be able to put a "set -o vi" in your .bashrc...
I think you will have to press [Esc] first to put it in edit mode...
Try it out.

Type "set -o" to get a list of options - the only downside is that you won't be in emacs mode anymore, so arrows won't work (to scroll up, you'll have to type "[Esc]" then "k" for example).
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Question on bash command line

OS : RHEL / Oracle Linux 6.8 In bash shell, how can I replace a character under the cursor with another character ? In the below example , after I typed the following line, I realized that I meant 7013 and not 2013. So I move the cursor to the left and keep it on top of 2 (of 2013) and I want... (7 Replies)
Discussion started by: kraljic
7 Replies

2. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies

3. Shell Programming and Scripting

Cp command works on command line but not in bash

The below command moves all the .vcf files into the directory. cp /home/cmccabe/Desktop/test/vcf/overall/stats/*.vcf /home/cmccabe/Desktop/NGS/annovar When I use a bash wrapper the target.txt gets created but the text files do not get copied. All the paths are the same, but not sure why... (2 Replies)
Discussion started by: cmccabe
2 Replies

4. Shell Programming and Scripting

Bash - Loading a command's output line by line into an array

I have been trying this a lot of different ways and haven't found too much online. Here's what I've got so far: j=0 declare -a first zero=(`cat $tmpfile`) for i in "${zero}" do command $i >> "${first}" ... (4 Replies)
Discussion started by: Azrael
4 Replies

5. Shell Programming and Scripting

bash, command line substitution

I have one script calling another with a set of strings that includes white space. Script A calls Script B with these input strings: one two "th ree" Script B pulls apart the arguments correctly: arg0 = one, arg1 = two, arg2 = "th ree" if I call it from within Script A like so:... (10 Replies)
Discussion started by: skippyV
10 Replies

6. UNIX for Dummies Questions & Answers

Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing set you can also use them "on the command line when running a script..." and it lists this in a small table: set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies

7. AIX

Typing "bash" at the command line spawns two bash processes

Server: IBM p770 OS: AIX 6.1 TL5 SP1 When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Discussion started by: wjssj
2 Replies

8. UNIX for Dummies Questions & Answers

ksh command line editing text being overwritten

hi. i'm using ksh with set -o vi. if i am far down in a directory and try to edit the command line (esc-k to retrieve previous command) the cursor is being positioned over to the left on top of the directory text making the text very difficult to read or work with. seems to be problem with long... (2 Replies)
Discussion started by: jeffa123
2 Replies

9. Shell Programming and Scripting

Single line file editing command?

Hello everyone. I have been reading a lot about the various different text editors at my disposal through Unix, but I just can't seem to close the deal for what I am trying to do. Is there a way to issue a single line command to edit a file where pattern=x, and do it non-destructively AND in-place?... (1 Reply)
Discussion started by: gator76
1 Replies
Login or Register to Ask a Question