Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell command history messing up when switching windows/slices #1671

Closed
afrixs opened this issue Apr 9, 2019 · 5 comments
Closed

Shell command history messing up when switching windows/slices #1671

afrixs opened this issue Apr 9, 2019 · 5 comments

Comments

@afrixs
Copy link

afrixs commented Apr 9, 2019

My shell command history gets messed up when I switch among the terminals while running long-running commands in them. This happens when HISTCONTROL=ignoreboth is set in .bashrc or when set -g @resurrect-save-shell-history 'on' is set in .tmux.conf.
Since resurrect-save-shell-history is an experimental part of a tmux plugin, I'm going to concern on the basic usecase with HISTCONTROL=ignoreboth set.

How I reproduce it:
.bashrc:

case $- in
    *i*) ;;
      *) return;;
esac
HISTCONTROL=ignoreboth

.tmux.conf: empty

commands:
tmux
Ctrl+C
top
Ctrl+C (stops top)
prefix+c
ls
prefix+0
Up arrow (displays top)
Enter (runs top)
prefix+1
ls
prefix+0
Ctrl+C (stops top)
Up arrow (displays ls, should display top)

System: Ubuntu 18.04.2 LTS
Terminal: reproduced both in Ubuntu terminal and Konsole
$TERM (inside mux): screen-256color
$TERM (outside mux in both in Ubuntu terminal and Konsole): xterm-256color
tmux -V: tmux next-3.0
logs:
tmux-server-32284.log

Bug does not occur after removing HISTCONTROL=ignoreboth from .bashrc.

Note: while dealing with this issue I created a hack which overcomes it, so for those who experience similar problems and want to use the command history temporarily while the bug is not fixed, this is a script that performs custom history saving (it uses $HOME/.tmux/resurrect/ path for saved history files to be compatible with @resurrect-save-shell-history but this path can be changed if you don't use tmux_resurrect), just put it into .bashrc. Note2: the history starts working correctly in each individual terminal after executing the first command (ie. " echo >> 0" with the leading space)
tmux_history_bug_hotfix.txt

@nicm
Copy link
Member

nicm commented Apr 9, 2019

This sounds like a Bash problem, not a tmux problem?

@afrixs
Copy link
Author

afrixs commented Apr 9, 2019

found some bugs in the workaround, gonna fix it in the evening

@nicm
Copy link
Member

nicm commented Apr 9, 2019

There is no way for tmux to affect the shell history, it is entirely within the shell's control. You will need to ask the Bash developers.

@nicm nicm closed this as completed Apr 9, 2019
@afrixs
Copy link
Author

afrixs commented Apr 10, 2019

Ok, going to report it there. Just adding the corrected workaround script if someone finds this thread with the same problem (see the notes at the top of the script)
start_alternative_tmux_history_saving.txt

@lock
Copy link

lock bot commented Feb 14, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants