Tmux install - nutthawit/alpine-dotfile GitHub Wiki
apk add tmux tmux-doc
cd ~/.dotfile
# Tmux resurrect pluging for save sessions across machine reboot
git clone https://github.com/tmux-plugins/tmux-resurrect.git
stow -v tmuxMake sure you have following aliases in ~/.ashrc
alias tns="tmux new -s"
alias tls="tmux ls"
alias tat="tmux attach -t"
alias tatt="tmux attach -t"
alias tks="tmux kill-server"Source your ~/.ashrc to active aliases
source ~/.ashrcThe problem is when you open Neovim with nvim . to view all files in the current directory, the tmux session will record that directory. If you have edited some files in that directory and exit your tmux session, the resurrect plugin will remember and restore that directory, but not your currently open files.
To solve this, we need to create a Session.vim file (The resurrect plug will looking up) to save the current files you have open in that directory. We will use the Vim plugin named vim-obsession to help you in that case.
- Install plugin
PLUGIN_NAME=vim-obsession
mkdir -p ~/.config/pack/$PLUGIN_NAME/start
git clone https://github.com/tpope/vim-obsession.git $PLUGIN_NAME-
Re-open nvim
-
Create file
Session.vimwith:mksession
After you make changes to a file, you need to run the Vim command :cd %:h followed by :mksession.
[!WARRING] The
Session.vimfile can be overwritten. If you have multiple tmux panes open with multiple files in the same directory and run:mksession!, the session file (Session.vim) will overwrite each other. Consequently, when you restore the tmux session, the last file saved will be displayed in all panes.
Dealing with copy/paste from an editor like Helix running inside tmux requires combining the copy mechanism of the editor, the copy mechanism of the terminal multiplexer, and the system clipboard utility.
Since you're using Helix, you're likely using its Vi-style selection. Here's the most robust way to set up your system for seamless copy/paste:
1. Configure Helix for System Clipboard
First, you need to ensure Helix is configured to use your system's clipboard when you yank (y). Helix primarily uses the clipboard utility, which usually relies on environment variables or specific commands like xclip, wl-copy, or pbcopy.
Helix should default to using the system clipboard if it finds the right utility in your $PATH. If not, check your Helix configuration file (usually in ~/.config/helix/config.toml) for a [editor] section. Ensure that the default behavior isn't being overridden.
Test:
- In Helix, select some text.
- Press
yto yank. - Open a non-terminal application (like a web browser) and press
<Ctrl-v>or<Cmd-v>.- If the text pastes, Helix is correctly using the system clipboard.
- If it doesn't, ensure you have a clipboard utility installed and available in your environment (
xclipfor X11,wl-clipboardfor Wayland, orpbcopyfor macOS).
2. Configure Tmux for System Clipboard Integration
If Helix is working but the problem is still in tmux, it's because tmux intercepts the yank command. You need to configure tmux to pipe its internal copy buffer to your system's clipboard utility.
In your ~/.tmux.conf file, add or confirm the following lines. Use the one that matches your operating system/environment:
For Wayland (using wl-copy):
# Use wl-copy for yanking to the system clipboard
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'wl-copy'
bind-key -T copy-mode-vi 'Y' send-keys -X copy-pipe-and-cancel 'wl-copy'
For X11 (using xclip):
# Use xclip for yanking to the system clipboard
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -selection clipboard'
bind-key -T copy-mode-vi 'Y' send-keys -X copy-pipe-and-cancel 'xclip -selection clipboard'
For macOS (using pbcopy):
# Use pbcopy for yanking to the system clipboard
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'pbcopy'
bind-key -T copy-mode-vi 'Y' send-keys -X copy-pipe-and-cancel 'pbcopy'
Reload Tmux Config:
After saving ~/.tmux.conf, run this command inside tmux to apply the changes:
# Press <Ctrl-b> (or your prefix) then : (colon)
# Then type the command below and press Enter
:source-file ~/.tmux.conf3. The Recommended Workflow
With the above configurations, you should use the following workflow:
A. Copying Text From Helix
- Enter Helix normal mode.
- Select text in visual mode (
v). - Press
y(yank).- Result: The text is copied directly to your system clipboard (thanks to Helix's integration) and is ready to paste anywhere (inside or outside the terminal).
B. Copying Text From Tmux (Scrollback/Shell Output)
If you want to copy shell output or scrollback history:
- Press the tmux prefix key +
[(Enter Copy Mode). - Press
v(Start Vi-style selection). - Move the cursor to highlight the text.
- Press
y(or whichever key you bound in step 2).-
Result: The text is copied to the system clipboard (thanks to the custom binding in
tmux.conf).
-
Result: The text is copied to the system clipboard (thanks to the custom binding in