1---
 2title: Fix bind warning in .profile on login in Ubuntu
 3url: bind-warning-on-login-in-ubuntu.html
 4date: 2020-09-08T12:00:00+02:00
 5type: post
 6draft: false
 7---
 8
 9Recently I moved back to [bash](https://www.gnu.org/software/bash/) as my
10default shell. I was previously using [fish](https://fishshell.com/) and got
11used to the cool features it has. But, regardless of that, I wanted to move to a
12more standard shell because I was hopping back and forth with exporting
13variables and stuff like that which got pretty annoying.
14
15So I embarked on a mission to make [bash](https://www.gnu.org/software/bash/)
16more like [fish](https://fishshell.com/) and in the process found that I really
17missed autosuggest with TAB on changing directories.
18
19I found a nice alternative that emulates [zsh](http://zsh.sourceforge.net/) like
20autosuggestion and autocomplete so I added the following to my `.bashrc` file.
21
22```bash
23bind "TAB:menu-complete"
24bind "set show-all-if-ambiguous on"
25bind "set completion-ignore-case on"
26bind "set menu-complete-display-prefix on"
27bind '"\e[Z":menu-complete-backward'
28```
29
30I haven't noticed anything wrong with this and all was working fine until I
31restarted my machine and then I got this error.
32
33![Profile bind error](/assets/posts/profile-bind-error/error.jpg)
34
35When I pressed OK, I got into the [Gnome
36shell](https://wiki.gnome.org/Projects/GnomeShell) and all was working fine, but
37the error was still bugging me. I started looking for the reason why this is
38happening and found a solution to this error on [Remote SSH Commands - bash bind
39warning: line editing not enabled](https://superuser.com/a/892682).
40
41So I added a simple `if [ -t 1 ]` around `bind` statements to avoid running
42commands that presume the session is interactive when it isn't.
43
44```bash
45if [ -t 1 ]; then
46  bind "TAB:menu-complete"
47  bind "set show-all-if-ambiguous on"
48  bind "set completion-ignore-case on"
49  bind "set menu-complete-display-prefix on"
50  bind '"\e[Z":menu-complete-backward'
51fi
52```
53
54After logging out and back in the problem was gone.