You are not logged in.

#1 2014-07-13 10:02:12

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Bash: shift + tab not working properly

Dear all,
I have just realized that the combination SHIFT+TAB does not work properly in bash.

When I am using an editor like vim or nano I would expect that hitting SHIFT+TAB would bring the cursor back,
instead in NANO it says that it is an unknown combination, while in vim it behaves as a tab.

I have used

cat -v

to discover that the combination SHIFT+TAB is mapped to

^[[Z

What should I do to have SHIFT+TAB behave as expected?

Thanks a lot in advance!

Offline

#2 2014-07-13 12:45:37

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Bash: shift + tab not working properly

You don't explain well what you expect from the Shift+Tab combination: unindent, delete backwards, move the cursor left n characters?  Is it bash or is it the two editors whose behaviors you wish to change?  For bash, I've never known Shift+Tab to do anything unless that key combination has been mapped by the user.

For vim, take a look at http://vim.wikia.com/wiki/Make_Shift-Tab_work.

Offline

#3 2014-07-13 13:15:18

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

Thanks Old man,
I honestly don't know what to expect. Isn't shift+tab supposed to do the opposite of tab?
That is, if in a program tab indent 4 char, I expect shift+tab to unindent them,
if in bash TAB switches between the various choices (I haven't set this yet), I think shift tab should go in reverse order.
In vim I have set this behavior using .vimrc and it works fine on an Ubuntu machine having the same .vimrc file
(unfortunately I don't have access to it anymore).

If I understood correctly while reading reading, SHIFT+TAB is mapped to ^[[Z] when something is not configured properly.
I would first like to fix that, and then when it is mapped to the right combination, I will check how to configure the various
programs to behave as I would like.

Thanks again for the help!

P.s. I had already tried the solution you posted for vim, but it doesn't work...

Offline

#4 2014-07-13 18:43:27

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Bash: shift + tab not working properly

Aha! Shift+Tab does work correctly for you, but your expectations are that it should work differently.

Changes to key bindings for bash + readline can be placed in either /etc/inputrc for system-wide modifications or in ~/.inputrc for per-user modifications.

For the filename completion, I think you actually want menu-completion.  Try adding the following lines to your ~/.inputrc file.

TAB: menu-complete
"\e[Z": menu-complete-backward

Press Ctrl+x then Ctrl+r to have the changes take effect in your current shell.

I'll note that this works for bash and probably won't be of use with other shells.  You are on your own if $TERM is incorrectly set.

Offline

#5 2014-07-14 20:53:41

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

Hi Oldman,
actually I don't want to set the menu-complete.

I just noticed that Shift+Tab behaves differently than in other linux installation (with the same configuration files),
which is why I thought something is wrong with my configuration.

Since following the links to set up vim that you sent me didn't work, I still think there might be some problem with my setup.

I have TERM set to xscreen-256color can this be a problem?

Offline

#6 2014-07-14 23:25:12

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Bash: shift + tab not working properly

Which terminal emulator or emulators are you using?

Where are you setting $TERM? Do you have a typo in your previous post? I cannot find a terminfo file named 'xscreen-256color'.  I can find 'screen-256color'.

I follow the generally good advice to never export TERM. Exporting TERM can mess up console terminals as well as the different terminal emulators I use. 

I use my X resources files for 256 color xterm with:

xterm*termName: xterm-256color

Urxvt sets its own $TERM correctly for me, rxvt-unicode-256color.

I set the TERM variable for tmux in ~/.tmux.conf with this line:

set -g default-terminal "screen-256color"

Offline

#7 2014-07-14 23:34:28

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

Thanks, clearly I got it wrong, I meant xterm-256color.

What is the X resources file, can you send me a link?

Anyway, one of the problem I had is that I exported TERM in .profile.
If you do so, the term value set in .tmux.conf is overridden, which causes problems.

Now I only set term in bashrc, but if there is any better way, I'd like to change it.

Thanks again for all the help!

Offline

#8 2014-07-15 00:17:49

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,381
Website

Re: Bash: shift + tab not working properly

Don't set TERM at all: that is just going to break things.

You can set default-terminal in tmux, which should be sufficient.


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#9 2014-07-15 02:02:27

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 252

Re: Bash: shift + tab not working properly

OP, If you are using vi then the standard way to shift right by one indentation width is to use ctrl+t, and shift left with ctrl+d. Those will move whatever your "shiftwidth" setting is, which may not be 8 chars of course. And if you are a vi/vim user then you are far better of to use vi editing mode in bash, i.e. add "set -o vi" to your ~/.bashrc, and add a line "set editing-mode vi" in your ~/.inputrc.(for readline based apps). I also suggest adding a "shopt -s lithist" in your .bashrc so that in bash you can press "v" and editing large command history lines in vim with full line wrap etc.

Offline

#10 2014-07-15 07:46:42

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

jasonwryan wrote:

Don't set TERM at all: that is just going to break things.

You can set default-terminal in tmux, which should be sufficient.

But if I don't set TERM I don't have 256 colors in my Bash shell...

Offline

#11 2014-07-15 07:48:14

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,381
Website

Re: Bash: shift + tab not working properly

That's not the way to fix that problem: see thisoldman's post at #6.


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#12 2014-07-15 07:54:52

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

bulletmark wrote:

OP, If you are using vi then the standard way to shift right by one indentation width is to use ctrl+t, and shift left with ctrl+d. Those will move whatever your "shiftwidth" setting is, which may not be 8 chars of course. And if you are a vi/vim user then you are far better of to use vi editing mode in bash, i.e. add "set -o vi" to your ~/.bashrc, and add a line "set editing-mode vi" in your ~/.inputrc.(for readline based apps). I also suggest adding a "shopt -s lithist" in your .bashrc so that in bash you can press "v" and editing large command history lines in vim with full line wrap etc.

I haven't followed much Bulletmark smile. I use only vim (never vi). What does

 set -o vi

and 

set editing-mode vi

do?
What is vi editing mode?

I like my configuration now, I just fear that having set TERM manually, might have messed things a little.
However leaving TERM to the default (i.e. xterm) while I do not have 256 colors in the bash shell, I have them in vim, which for the moment is fine.

I have tried to set 256 colors in bash modifying .Xresources and .xinitrc, but without success..

Offline

#13 2014-07-15 08:04:32

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,381
Website

Re: Bash: shift + tab not working properly

thisoldman wrote:

I use my X resources files for 256 color xterm with:

xterm*termName: xterm-256color

Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#14 2014-07-15 08:32:38

HiImTye
Member
From: Nanaimo, BC, Canada
Registered: 2012-05-09
Posts: 403

Re: Bash: shift + tab not working properly

bulletmark wrote:

add "set -o vi" to your ~/.bashrc, and add a line "set editing-mode vi" in your ~/.inputrc.

you just completely changed my shell for me. I'm a little sad that I didn't know this before just now

Offline

#15 2014-07-15 08:43:24

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

jasonwryan wrote:
thisoldman wrote:

I use my X resources files for 256 color xterm with:

xterm*termName: xterm-256color

It doesn't work for me.

I have also added the following to .xinitrc:

[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources

but still when I restart my shell have TERM set to xterm.

Ps. I forgot to mention I am using LightDM and MATE desktop running automatically at startup.

Offline

#16 2014-07-15 09:01:56

slithery
Member
Registered: 2013-12-01
Posts: 800

Re: Bash: shift + tab not working properly

.xinitrc only gets called if you use startx, if you use a DM then it never gets read.

Offline

#17 2014-07-15 09:42:42

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

slithery wrote:

.xinitrc only gets called if you use startx, if you use a DM then it never gets read.

Thanks Slithery, I got this wrong then smile

So why is the .Xresources file not applied? Should I put the xrdb line somewhere else?

Offline

#18 2014-07-15 09:45:21

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,381
Website

Re: Bash: shift + tab not working properly


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#19 2014-07-15 12:40:36

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

The problem I am having though doesn't appen only at startup...

If I do manually

xrdb -merge .Xresources

TERM still doesn't get changed.

Offline

#20 2014-07-15 16:08:22

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Bash: shift + tab not working properly

lucacerone wrote:

The problem I am having though doesn't appen only at startup...

If I do manually

xrdb -merge .Xresources

TERM still doesn't get changed.

You may have a typo or an error in a line in your .Xresources.  I've noticed if there is an error in an X resource file, xrdb bails and any lines after the error are not processed.

Offline

#21 2014-07-15 16:41:10

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

it contains only that line...

Offline

#22 2014-07-15 19:22:48

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,381
Website

Re: Bash: shift + tab not working properly

Just to make sure, use the full path:

xrdb -merge /home/lucacerone/.Xresources

Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#23 2014-07-16 07:20:20

lucacerone
Member
From: Spain
Registered: 2012-05-04
Posts: 144
Website

Re: Bash: shift + tab not working properly

nothing... I also tried to enclose the full path in '' and "" but it does not change things...

Offline

#24 2014-07-16 10:42:35

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: Bash: shift + tab not working properly

Just to eliminate the obvious, did you start a new instance of xterm after the xrdb command?

Edit: Try starting an xterm instance using the command:

$ xterm -tn xterm-256color

Last edited by thisoldman (2014-07-16 16:49:34)

Offline

Board footer

Powered by FluxBB