31

On centos I can skip a word by hitting ctrl + arrow (left or right) in a terminal. When I ssh into a FreeBSD box and I try the same pattern I get:

$ tail -f 20120412.log;5D;5D;5D

(each try = ;5D)

Is there a way to fix this? I am using Ubuntu 12.04 + Terminator.

Thanks in advance.

jdorfman
  • 413
  • 4
  • 7

5 Answers5

44

A .inputrc in your home directory will cause ctrl+left to stop working on Ubuntu (for example).

To get everything working, add the following to ~/.inputrc:

# Include system-wide inputrc, which is ignored by default when
# a user has their own .inputrc file.
$include /etc/inputrc
CoolOppo
  • 103
  • 3
f.kowal
  • 541
  • 4
  • 3
  • 2
    To clarify - this `.inputrc` should be set on remote machine. – omikron Mar 09 '16 at 11:22
  • worked for me, only after restarting byobu though. – immeëmosol Nov 15 '16 at 10:51
  • 3
    For anyone that is entirely missing their `.inputrc`, the relevant lines for me were: `"\e[1;5C": forward-word`, `"\e[1;5D": backward-word`, `"\e[5C": forward-word`, `"\e[5D": backward-word`, `"\e\e[C": forward-word`, `"\e\e[D": backward-word` – AlbinoDrought Apr 05 '19 at 16:39
  • This doesn't work for me. – einpoklum Feb 09 '20 at 16:25
  • @immeëmosol, use ```source ~/.bashrc ; exec bash``` to restart in place. worked for me – alchemy Mar 28 '20 at 17:33
  • FYI, it did cause other problems with pasting lines of code that had escape characters in it. It seems to be resolved now that the shell restarted ,so YMMV on my command above. – alchemy Mar 28 '20 at 19:36
4

If You use ZSH, then use this at /etc/zshrc file.

case "${TERM}" in
  cons25*|linux) # plain BSD/Linux console
    bindkey '\e[H'    beginning-of-line   # home 
    bindkey '\e[F'    end-of-line         # end  
    bindkey '\e[5~'   delete-char         # delete
    bindkey '[D'      emacs-backward-word # esc left
    bindkey '[C'      emacs-forward-word  # esc right
    ;;
  *rxvt*) # rxvt derivatives
    bindkey '\e[3~'   delete-char         # delete
    bindkey '\eOc'    forward-word        # ctrl right
    bindkey '\eOd'    backward-word       # ctrl left
    # workaround for screen + urxvt
    bindkey '\e[7~'   beginning-of-line   # home
    bindkey '\e[8~'   end-of-line         # end
    bindkey '^[[1~'   beginning-of-line   # home
    bindkey '^[[4~'   end-of-line         # end
    ;;
  *xterm*) # xterm derivatives
    bindkey '\e[H'    beginning-of-line   # home
    bindkey '\e[F'    end-of-line         # end
    bindkey '\e[3~'   delete-char         # delete
    bindkey '\e[1;5C' forward-word        # ctrl right
    bindkey '\e[1;5D' backward-word       # ctrl left
    # workaround for screen + xterm
    bindkey '\e[1~'   beginning-of-line   # home
    bindkey '\e[4~'   end-of-line         # end
    ;;
  screen)
    bindkey '^[[1~'   beginning-of-line   # home
    bindkey '^[[4~'   end-of-line         # end
    bindkey '\e[3~'   delete-char         # delete
    bindkey '\eOc'    forward-word        # ctrl right
    bindkey '\eOd'    backward-word       # ctrl left
    bindkey '^[[1;5C' forward-word        # ctrl right
    bindkey '^[[1;5D' backward-word       # ctrl left
    ;;
esac
vermaden
  • 41
  • 1
2

Unless you have changed these from default, the shell that you're using on Ubuntu is bash. On FreeBSD, the default shell is csh. You can change your shell with the following command in both OSs:

chsh

Set your shell in FreeBSD to /usr/local/bin/bash. Bash is not part of FreeBSD, so if you haven't already, install it from ports:

cd /usr/ports/shells/bash
make install
make clean

One last thing: don't change the shell for root. This is what the "toor" account is for: all the privileges of root, but you can set the shell to whatever you want. The reason being that there aren't any system activities that run under toor, so you won't break anything or confuse anyone by changing that account's shell to something you are used to (or may be more functional as a login shell).

Aaron C. de Bruyn
  • 578
  • 10
  • 28
Utkonos
  • 332
  • 3
  • 12
0

Looks like you might have the wrong $TERM setting. echo $TERM to find out what your current setting is. Might want to use xterm export TERM=xterm-256color.

kasperd
  • 29,894
  • 16
  • 72
  • 122
-1

The shell you're running on the FreeBSD machine probably doesn't support that control sequence. Without knowing what shell you're running on either end, though, it's hard to say for sure.

wfaulk
  • 6,828
  • 7
  • 45
  • 75