Strange terminal mode, bash's mistake? - linux

Recently my bash has often got into strange states I don't understand (debian squeeze system). For example, after starting a new xterm, Control-l prints "^L" on my screen instead of cleaning it. This happens with a "fresh" xterm, with bash as well as with dash (even xterm -e /bin/dash). Also, a reset did never help.
By contrast, after ssh'ing to another box, Control-l does what I expect.
Can somebody make an educated guess for the cause to this very odd behaviour to me (my Unix knowledge can't help out)?

Sorry, I found it out. set -o vi was the culprit, as for bash. As for dash, it's just normal behaviour... Been a hard one.

Check the stty -aoutput and the $TERM variable. $TERM should be "xterm" or "xterm-color"

Related

Run gnome-terminal from tty

How can I run gnome-terminal from tty1?
I tried setting $DISPLAY variable to :0, but still nothing and gnome-terminal doesn't appear in the X window system.
However, xterm and firefox, work fine from tty1.
What am I missing?
What do you mean by tty1?
Did you run xstart when you were on tty1 and got a GUI where you expect everything to run?
It is possible that gnome-terminal expect some familiar desktop environment but crash due to lack of one. It is possible that you will need to specify the Xorg display with --display=DISPLAY option even if there is only one display.
Run gnome-terminal --help-all and read the output for more info.
Sorry for asking you questions in answer section but I apparently don't have enough reputation to add a comment.

Terminal does not seem to have reverse-i-search (ctrl-r does nothing)

I'm ssh-ing into a remote machine and when I try to search my history in a linux terminal with reverse-i-search, nothing happens. I press ctrl-r as I usually do on my machine, but the prompt doesn't appear.
Any ideas? How can I check the keybindings for ctrl-r? How do I set them if they aren't set? Do I have to apt-get reverse-i-search functionality?
Thanks!
To use ctrl-r your shell needs to be using readline (or something similar), your history should be collected.
So you should verify your shell for example sh doesn't support this.
You should check it the history is collected. For example with bash shell: echo $HISTFILE
I think these can be the main reasons.
Hopefully with simply entering bash, you can switch to a proper shell which will support this.

how to configure default TERM in screen session?

When invoke vi in a session inside SCREEN, I always encounter error:
bash-3.2$ vi perf332.db2
ex: 0602-108 screen is not a recognized terminal type.
[Press return to continue]
[Using open mode]
After I explicitly export TERM=xterm or something, it works fine.
My SCREEN is running on a Linux server, and I SSH from there to a AIX server.
The default TERM variable for screen is TERM=screen. This is what its supposed to be.
You might consider putting something like this in your .bashrc to change the TERM variable to xterm when its screen.
if [[ $TERM = screen ]]; then
export TERM=xterm
fi
However I do not recommend doing this as this might confuse other application.
It seems vi does not know how to send commands to screen when the TERM variable is set to screen. The other way of getting around this would be to install vim which does understand how to communicate with screen.
Try putting shell -$SHELL into your ~/.screenrc file

getting vi and rxvt to work in cygwin

I am trying to use rxvt on my cygwin w win XP but the terminal appears and disappears. What could be wrong? This is true for all except rxvt-native . I have tried a few commands found online but with no success. I include 2 I have tried:
start C:\cygwin\bin\rxvt.exe -sb -sl 3000 -fg gray -bg black -fn "Lucida Console-14" -e /bin/bash --login -i
.
path C:\cygwin\bin;%path%
ssh-agent rxvt -e bash --login -i
Another problem I am facing is trying to get vi to work in my cygwin bash shell. Setting term to xterm or vt100 does not work. Hitting enter, I see a string 78 or some other issue pops up. I have never modified my .inputrc.
My main issue was trying to get vi to work properly. I just found out that if I run
/etc/postinstall/terminfo.sh.done , I can now navigate properly in vi. The 78 (newline) M still appears but at least I can navigate in vi.
Feb 25 - This problem went away after a few windows updates. Would it make sense to ANSWER my question on the basis that this is longer reproducible?
Can't answer the first question, but have you tried invoking rxvt from its shortcut in the Cygwin folder of the start menu?
Regarding the second question, the TERM variable tells applications what terminal they're running in, so if you set it to 'xterm' while running in the Cygwin console (where normally TERM=cygwin), they'll be sending xterm control sequences that the Cygwin console doesn't understand. So basically: don't do that!
Btw, you might also be interested in Cygwin's mintty package, which is another terminal that doesn't need an X server. Installing it also creates a start menu shortcut in the Cygwin folder.
I would assume you need an X server running.
You could install Cygwin/X
One thing which may not have been clear was that the whole exercise was to get vi to work. vim did not work either at that time. But after some windows update, the problem went away. Closing it...

Screen + vim causes shift-enter to insert 'M' and a newline

When running a vim instance in gnu screen hitting shift enter in insert mode adds an 'M' and then a newline, rather than just a newline.
Does anybody know what the problem might be, or where to look?
Relevant system info:
Ubuntu 8.04.1
Screen version 4.00.03 (FAU) 23-Oct-06
VIM - Vi IMproved 7.1 (2007 May 12, compiled Jan 31 2008 12:20:21)
Included patches: 1-138
Konsole 1.6.6 (Using KDE 3.5.10)
Thanks to the comments. When checking the value of $TERM I noticed that it was xterm (as expected), but within screen $TERM was set to screen-bce. Setting TERM=xterm after launching screen resolves this issue.
Adding the following to ~/.screenrc solved the problem without having to do anything manually:
term xterm
Missing info from your question:
Where do you run screen and see this issue? Some terminal app (KTerminal, Gnome terminal, virtual console etc) or remote session (eg putty, ssh from another computer)
do a “echo $TERM” and tell us its output
do a “cat -v”, press Shift-Enter, then Enter, then Ctrl-D and then tell us what is output.
First, you could fix your $TERM for within konsole. Install "ncurses-term" and configure konsole to set $TERM=konsole-256color. Then configure screen with "term screen-256color". Or 'konsole' and 'screen', respectively, if that's your preference. Konsole and screen are not xterm and doesn't support everything xterm does, so using incorrect $TERM can lead to bad things.

Resources