WSL环境下Windows控制台最小化恢复后内容上移一行的解决方法?
Hey there, fellow WSL and tmux/Vim user! I’ve dealt with this exact frustrating issue before—nothing throws off your workflow like your fullscreen apps getting shifted after a simple minimize. Let’s go through the most reliable fixes that worked for me and other developers in the community:
Quick Manual Fix (Immediate Relief)
- If you just need a quick fix right now, run the
resizecommand in your terminal. This utility automatically detects the current window dimensions and adjusts the tty settings to match, instantly correcting the shifted content.
Tmux-Specific Permanent Fix
If you use tmux regularly, adding these lines to your ~/.tmux.conf will make it auto-adjust to window size changes:
# Auto-update tmux pane size when terminal resizes set -g aggressive-resize on # Ensure environment variables related to window size are passed through set -g update-environment "DISPLAY WINDOWID XAUTHORITY"
After saving the config, restart tmux with tmux kill-server && tmux for the changes to take effect. Now tmux will automatically fix the layout whenever you restore the window.
Windows Terminal Settings Tweaks
If you’re using Windows Terminal (the default for WSL these days), try these adjustments:
- Disable Hardware Acceleration: Open Windows Terminal settings → Go to "General" tab → Uncheck "Enable hardware acceleration". Some GPU/driver combinations cause rendering glitches that lead to this shift.
- Verify Window Resize Behavior: For your WSL profile, go to "Advanced" → Ensure "Adjust window size when reflowing output" is enabled. This makes the terminal re-calculate content layout when the window size changes.
Update WSL and Terminal Components
Old versions of WSL or Windows Terminal often have bugs that cause this issue:
- Open PowerShell as Administrator and run
wsl --updateto get the latest WSL kernel. - Update Windows Terminal via the Microsoft Store to ensure you have the latest bug fixes.
Vim-Specific Adjustment
If the issue persists in Vim alone, add this line to your ~/.vimrc to force Vim to re-draw the screen when the window resizes:
autocmd VimResized * redraw!
This triggers a full screen redraw whenever Vim detects the terminal window has changed size.
Hope one of these solutions gets rid of that annoying shift for you! Let me know if you need help troubleshooting any of these steps.
内容的提问来源于stack exchange,提问作者iBug

