bash history and command line wrapping


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers bash history and command line wrapping
# 1  
Old 07-02-2009
bash history and command line wrapping

By default, we use ksh (88) as our shell. I prefer bash, so I added this line to my .profile:
Code:
exec bash -o vi

I also added this to my .bashrc?:
Code:
#***********************************************
#These are important tweaks specific to BASH:
#***********************************************
#this one makes sure that long commands strings line wrap to the next line
[ -z "$PS1" ] && return

#instead of wrapping onto the start of the same line.
shopt -s checkwinsize

#this corrects typos when spelling out paths.
shopt -s cdspell  

alias c=clear

Of course, the alias works fine, however, when I try to use the up key to pull up a previous command from the history, it doesn't work until I press the down key first. I also can't get the line wrapping to work correctly. When I start with a prompt like this:
Code:
myBashPrompt>

I end up with this after a long command:
Code:
andashPrompt> This is what happens when I type a really long comm

If you noticed, the wrap overwrote the prompt. How do I get this to wrap correctly onto a new line? Also, how do I get my bash history to come up without having to press down, up?

I should also mention that I am using putty to ssh into our machines.

Last edited by mrwatkin; 07-02-2009 at 01:56 PM..
# 2  
Old 07-03-2009
There is probably a term mismatch. Try telling putty to use vt220. And in the settings window, there is a section for "keyboard". You might want to experiment with different keyboard emulations. Usually the "Esc" is preferred.

To match this on the unix side, throw this into the .profile/.bashrc:
Code:
export TERM=vt220

You can also try xterm-color or xterm-ansi or just ansi.

There are several ways to tell bash to use the "vi" command-editing mode, but if you are only familiar with up/down arrow keys, then you might want to use "set -o emacs". Additionally, there's a file called ".inputrc" which is read normally by bash and will configure the keyboard how you like. Look at the manpage for "readline".
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Converting a list to X columns of csv (& wrapping a command around it)

Hi All, Random question, how would you convert a data file from a list like so: 12345 12346 12347 12348 12349 12350 ... <snip 100+ lines> ... to comma separated X columns across: 12345,12346,12347 12348,12349,12350 Why would you want to do this? The background to this is a... (2 Replies)
Discussion started by: craigp84
2 Replies

3. Shell Programming and Scripting

Line Wrapping using Sed

Hi, I want to wrap the lines if a line starts with number. I tried the following sed command, but I do not get the required output. It is replacing the first number. Can some one please help me on this? Command I used sed -e :a -e '$!N;s/\n//;ta' -e 'P;D' testfile I/P file:... (2 Replies)
Discussion started by: christineidanny
2 Replies

4. Shell Programming and Scripting

What is the ksh equivalent to bash's "history -c" command?

Hi, What is the korn shell equivalent of bash shell's "history -c" command? I do know, how to clear the history list in ksh, I can do the following: > ~/.sh_historybut still, I am interested to know the single one line command as 'history -c' gives error on my ksh (1 Reply)
Discussion started by: royalibrahim
1 Replies

5. AIX

command line history of others

As a newbie sys admin, how do i find out what other login session command line history, what are the commands they used? Thanks. leim (4 Replies)
Discussion started by: leim
4 Replies

6. Shell Programming and Scripting

find command and wrapping in the script

Hello, I've been trying to use find command to find and print out some files. When I execute the command on the command line I get the output as expected howerver when I run it in the script it doesn't wrap. For example, this is nicely wraped find /etc -perm -o=w -exec ll '{}' \;... (4 Replies)
Discussion started by: mirusko
4 Replies

7. Solaris

^p not giving command line history.

I am used to using "set -o emacs" and then using "CNTL-P" for getting previous commands in solaris but on one host it does not work and instead just makes a DONG!! # ksh # set -o emacs # ls # ^p Can anyone offer guidance as to why this is? Thank you my friends. akbar (0 Replies)
Discussion started by: akbar
0 Replies

8. UNIX for Advanced & Expert Users

command line history

I am running Solaris 8 and using ksh. The history file (.sh_history) helps a lot, but it seems to get 'reset' after a certain period of time. In other words, after some usage of the shell, the command history would disappear and start anew. Is there some facility to specify the period of time to... (1 Reply)
Discussion started by: Sowser
1 Replies

9. Shell Programming and Scripting

Line wrapping problem when using awk

I am fairly new at this, I wrote a awk program to give me some summary information about a file. At the end of the program I want to print some variables but for some reason it keeps wrapping the last variable on a new line in the output file. Here is the print command print "99", file_id,... (1 Reply)
Discussion started by: placroix1
1 Replies

10. Shell Programming and Scripting

Wrapping a bash script for CGI

I hope its ok to start a new thread, I was going to use my existing one but thought a new one would better clarify things and provide better search for future reference. Well I have my bash program working now, all nice, user input validated, output formatted, everything is looking sexy. Now... (2 Replies)
Discussion started by: andyj
2 Replies
Login or Register to Ask a Question