How to have my mouse wheel scroll the screen on zsh? - terminal

I use zsh 5.0.2 on Ubuntu 14.04.1 LTS via SSH with Tera Term 4.84.
My .zshrc is here (my username is replaced with $USERNAME):
# Lines configured by zsh-newuser-install
HISTFILE=~/.zsh_history
HISTSIZE=50
SAVEHIST=50
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/$USERNAME/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
PROMPT="%n#%m:%c%# "
In my shell, when I rotate the mouse wheel,
the command history moves instead of scrolling the screen.
Zsh 4.3.17 on another host (Ubuntu 12.04.5 LTS)
can be scrolled well with mouse wheel with the same client.
How can I make my zsh scrolled with my mouse wheel without pressing the Ctrl key?
This question is also asked here (in Japanese): http://dixq.net/forum/viewtopic.php?f=3&t=15586

As #jimmij pointed out, this is an issue with Tera Term, not zsh.
According to the Tera Term documentation there are 2 configuration options that control the behavior of the mouse's scroll wheel: TranslateWheelToCursor and DisableWheelToCursorByCtrl. Their default values are:
TranslateWheelToCursor=on
DisableWheelToCursorByCtrl=on
Setting TranslateWheelToCursor=off should disable the default scroll wheel behavior.

Related

How do you scroll up/down using your mouse/keyboard in Git Bash?

I'm running windows 10 and I've just installed Git version 2.29.2.windows.2
I'm trying to learn Git on Udemy and the instructor can clear his screen by typing clear. However, he can also scroll up and down to see the commands he'd previous typed after he's cleared them. I'm unable to do that. I can't scroll with the mouse. Page up/Down don't do anything and nor do the arrow keys. Once I've typed clear, all my previous commands seem to disappear and I can't access them. I've had a look at the Git Bash options and I can't see anything which would fix this. I've also searched this site for answers but the most recent one I could find was from 2016 and is out of date and doesn't work.
Could anyone explain how I can scroll once I've entered clear so that I can see my previous commands? Thanks.
It's not normal for the mouse scroll to retrieve history entries. It usually scrolls up the terminal window. Here are a few things to try.
Make sure you're using the Git Bash terminal using Mintty, not the Windows command prompt running bash.
Up-arrow and down-arrow are the same as Ctrl-P and Ctrl-N.
Run stty sane.
Do bind -p |less and look at the entries for next-history and previous-history. They should look like:
"\C-n": next-history
"\eOB": next-history
"\e[B": next-history
"\C-p": previous-history
"\eOA": previous-history
"\e[A": previous-history
Check your ~./inputrc and /etc/inputrc files.
Read the Bash man page sections for READLINE and bind.

Docker Toolbox Terminal/Git Bash problems with backspace

Until recently, I was able to use an .inputrc file for defining the backspace key as meaning delete-char in bash but a few days ago, Docker Toolbox updated automatically and now bash doesn't work anymore.
Here is what I'm doing
Start the "Docker Quickstart Terminal"
Run "docker-machine ssh"
At this point, I'm in a normal shell i.e. /bin/sh and the backspace works perfectly, but when I switch to bash, it suddenly stops working. Here is my .inputrc file, not sure if it helps, it worked before the update
set completion-ignore-case on
# ctrl-left/right
"\e[1;5C": forward-word # ctrl + right
"\e[1;5D": backward-word # ctrl + left
"\e\e": kill-whole-line
DEL: delete-char
"\e[1~": beginning-of-line
"\e[4~": end-of-line
I'm using Windows 10 with the falls creator update.
Docker Toolbox: v18.01.0-ce
Bash: GNU bash, version 4.4.0(1)-release
Terminal: Windows cmd.exe
I'm going to try identify the last version when it worked, but what I would like to know is if something changed in recent Docker Toolbox versions or if I just did something wrong.
Edit:
I tested around and apparently the boot2docker version 17.12 introduces this regression.
It seems this is a bug and I didn't do anything wrong. Tracked here: https://github.com/boot2docker/boot2docker/issues/1299

ZSH shell and CLion/PyCharm integration, movement around terminal

I'm trying to use zsh in the CLion terminal window (changed my shell to /bin/zsh)
But when I try to move around using Ctrl + Left, Ctrl + Right, Ctrl + E... I get the literal characters D, C and Ctrl + E opens the "Recent files" UI
Is there any way around this? I'd like to use the movement keystrokes as I can with bash.
Tempoz,
Check out the offical Zsh Line Editor doc and the Z-Shell Line Editor guide for tons of detail.
To start, you can see your current mappings by typing bindkey at your prompt. There are two start modes: emacs [default], and vi. If you want to use vi mode, add this to your ~/.zshrc
bindkey -v
and source it (or restart your shell, or restart your IDE). Check out how the bindkey output has changed.
If you decide you want to change or augment your key mappings, use bind in your ~/.zshrc to reassign, or add to your key map.
# Example key binding change
# bindkey key-sequence editor-command
bindkey '^Z' vi-kill-line
You will also probably want to fix your $PATH - all the JetBrains products do it incorrectly. See this answer: https://stackoverflow.com/a/51006003/1089228

Use Ctrl + Left/Right to move forward/back one word in tmux within Mobaxterm

When using tmux within Mobaxterm, Ctrl + Left/Right just moves the cursor forward/back one character, not one word.
In the following cases, Ctrl + Left/Right does behave as expected:
in bash within Mobaxterm
in screen within Mobaxterm
in tmux within Cygwin
in screen or bash within Cygwin
So it seems to be an issue only when combining tmux with Mobaxterm.
In all cases, I am ssh-ing to a remote linux machine, within either Cygwin or Mobaxterm. My /etc/inputrc is set as it should for the shortcuts to work.
Any clue?
Old question. But in case someone find his way here. This is sgzmd's answer:
Edit your ~/.tmux.conf and add lines:
set-window-option -g xterm-keys on
If you don’t want to make it permanent just yet, do:
C-b :set-window-option xterm-keys on
Reload your config in tmux by doing:
C-b :source-file ~/.tmux.conf
It worked for me.
original answer here

To bind clear to ^l in Bash

I would like to have Ctrl-l for clear in my Bash.
How can you bind Ctrl-l to clear in Bash?
Put this in your ~/.inputrc:
C-L: backward-kill-line
(assuming by "clear" you mean "clear current input line"; if you mean "clear screen" then put clear-screen instead of backward-kill-line).
in a particular case where the clear-screen didn't work for me either, I found out that putting in ~/.bashrc the line: bind -x $'"\C-l":clear;' was better than "\C-l":'clear\n' in ~/.inputrc because it cleared the screen and left the currently typed command in place; for example (^L show where I hit the combo):
With "\C-l": clear-screen in ~/.inputrc:
user#darkstar:~$ date^L
user#darkstar:~$ date
user#darkstar:~$ ^L
user#darkstar:~$
With "\C-l":'clear\n' in ~/.inputrc:
user#darkstar:~$ date^L
-bash: dateclear: command not found
user#darkstar:~$ ^L
# screen effectively redrawn
With bind -x $'"\C-l":clear;' in ~/.bashrc:
user#darkstar:~$ date^L
# screen redrawn and the top line is now:
user#darkstar:~$ date
And for now I have not been able to get the same result as bind -x using only the inputrc file...
Edit
I found that in some cases where clear-screen wasn't working for me were caused by my attempts to get more colors in the CLI.
For example I had the issue with TERM=xterm-256color (or screen-256color, etc.) and removing the -256color part solved the problem.
I have not yet found a way to get a 256 colors term working along CTRL+l (in xterm, urxvt, etc).

Resources