Comments (9)
@youngtuotuo
Ah ha, thank you! this feature is quite impressive too, and demonstrates the powerful customization capabilities of WezTerm.
BTW, Tabby has the feature where every time it reopens, it automatically restores all tabs that were open at the time of the last close.
from wezterm.
By the way, it's preferable for the tab title to remain unchanged before and after reconnecting via SSH.
This is because the tab title before the disconnection might have been "carefully" renamed, and it would be bothersome to rename it again with each reconnection.
from wezterm.
@daishengdong I think you can try this feature
https://wezfurlong.org/wezterm/config/lua/SshDomain.html
After properly setup, you can simply wezterm connect server-name
.
The only prerequisite is the remote machine also needs wezterm installed.
from wezterm.
@youngtuotuo
hi, the ssh_domain happens to be the method I'm currently using to establish SSH connections (in fact, this has troubled me before, as I was unable to install WezTerm on the target machine, and previously, because I did not add "multiplexing = None", the SSH connection was always unsuccessful):
The problem I described is precisely the one faced when establishing a connection in a new tab using the ssh_domain method; if I were to directly use "ssh name@ip" in a local shell, the tab for the local shell should not automatically close if the SSH connection drops.
My current approach is to establish an ssh_domain connection in a new tab through showLauncher (bound to a shortcut key), and if the SSH connection is lost, the tab also closes. A more user-friendly way, as I described in my issue, is for the tab not to close automatically and to allow triggering a reconnection directly within this tab(better with a shortcut key).
from wezterm.
- The root cause is
multiplexing = "None"
, this is the key feature of the tab restoration.
From the link I gave:
![image](https://private-user-images.githubusercontent.com/56819408/290727477-8d7b1bd8-f7c3-4d17-94e2-a786d4199a70.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTA4Njg3NTUsIm5iZiI6MTcxMDg2ODQ1NSwicGF0aCI6Ii81NjgxOTQwOC8yOTA3Mjc0NzctOGQ3YjFiZDgtZjdjMy00ZDE3LTk0ZTItYTc4NmQ0MTk5YTcwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzE5VDE3MTQxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQyNGIxYWE3NjY1YWI5MmU1Y2M1M2E4ODkwMjI5N2JhM2FmOTI3YTA2ZTlhZjk1ZWRjOTE2ZmI4MTU1OGNhMGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TIG-fgDLnKvIsPeRD_sHGo-2V4_63lpFGCEmTp3xOOY)
That's also why you were unable to connect without multiplexing="None"
, since you didn't install wezterm on your remote machine.
-
Simply use ssh command will not enable multiplexing feature, so it's normal that tab will close along with ssh disconnection.
-
I think you need to figure out how to install wezterm in your remote machine, otherwise, no seesion will be stored.
After endabling the multiplexing and installing wezterm on your remote machine, you can setup keyboard shortcut like this to detach/attach the ssh sessions
config.keys = {
{ key = "U", mods = "CTRL|SHIFT", action = act.AttachDomain("ubuntu") },
{
key = "D",
mods = "CTRL|SHIFT",
action = act.DetachDomain("CurrentPaneDomain"),
}
}
-
For Tabby/iTerm2 like restoration: when you close a tab, they just don't actually close them. They have a background process that handles all the connection, and, closing tab is simply closing UI, not closing ssh session, so that you can restore the ssh connections when you open the UI again.
This is a brand new featrue for wezterm, the implementation may take times. -
If install wezterm on your remote machine is impossible, I recommend use
tmux
with the normal ssh connection.
from wezterm.
@youngtuotuo
Yeah, I can get your point, if "multiplexing" then everything is ok.
But there is still a gap between us.
when you close a tab, they just don't actually close them. They have a background process that handles all the connection, and, closing tab is simply closing UI, not closing ssh session, so that you can restore the ssh connections when you open the UI again.
What I meant to say is not that "when the tab closes, the SSH session can still be maintained in the background by a standalone thread", but rather that "when the SSH session/network connection is lost, the tab still won't close." AND, If necessary, you can directly re-initiate the SSH/network connection on this "unclosed tab".
This doesn't require a separate thread, just a record of the relationship between the tab and the SSH domain, and providing an API that allows for the SSH connection to be directly re-initiated on the same tab.
I recommend use tmux with the normal ssh connection.
Yes, tmux can solve some problems, but not all, as the local machine could also shut down or restart, leading to the loss of the local tmux session.
The reason I'm making this feature request is that my work computer is a laptop, and my development machine is a remote server, so maintaining multiple ssh sessions is part of my daily development routine.
When I move my laptop between different networks, the SSH connection will drop.
If I have to go through the process of "1. using showLauncher to open SSH tabs, and 2. renaming the tabs to the name I want (since I have multiple remote servers)" every time, it becomes very annoying.
If the tab could be preserved after the network disconnects, it would be much more convenient to just use a shortcut key to re-initiate the SSH connection.
from wezterm.
@daishengdong Got it. Sorry that I misunderstood your needs.
I think your requirement is related to these (but not 100% aligned)
https://wezfurlong.org/wezterm/config/lua/gui-events/gui-startup.html
https://wezfurlong.org/wezterm/config/lua/mux-window/spawn_tab.html?h=spawn_tab#cwd
#3646 (comment)
Like this
local wezterm = require "wezterm"
local mux = wezterm.mux
wezterm.on('gui-startup', function()
local _, first_pane, window = mux.spawn_window {}
local _, second_pane, _ = window:spawn_tab {domain = { DomainName = 'ubuntu' }}
local _, third_pane, _ = window:spawn_tab {domain = { DomainName = 'rasberrypi'}}
local _, fourth_pane, _ = window:spawn_tab { args = { 'ssh debian2' } }
-- this is also a startup command
second_pane:send_text "<insert busybox command>\n"
third_pane:send_text "top\n"
-- '\n' this will execute you shell command
end)
Then every time you open wezterm, those tabs will automacically open.
from wezterm.
Duplicate of #2080
from wezterm.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
from wezterm.
Related Issues (20)
- Strange highlighted colors HOT 1
- CSI Sequences Not Parsed Properly HOT 1
- Doesn't work after upgrading to Plasma 6 on openSUSE
- format-tab-title with use_fancy_tab_bar results in invalid hover detection
- Pane resizing not working correctly when using multiplexer HOT 1
- The `windows.toast_notification()` function is not working properly. HOT 7
- Kitty keyboard: AltGr (ISO Level 3 Shift) and RCtrl (Compose) keys don't work HOT 4
- Allowing an accented character to appear simultaneously with its accent
- Allow scheduling an event from inside 'format-tab-title' event HOT 2
- Add sidebar with connections list
- Input lag when using wezterm on wayland
- Flatpak build unable to locate font glyph \u{f023} HOT 2
- Native package builds for aarch64 HOT 1
- MacOS: Text distorted and flickers during resizing window HOT 1
- Permission denied when calling docker HOT 1
- No keyboard events coming through on Wayland when front_end is "WebGpu" HOT 2
- Allow Speech Recognition (dictate) on macOS
- input delay after installing nvidia Vulkan Driver
- [Feature Request] Cool Retro Term Shaders?
- use ~or $HOME to set backgound is not work, and how to set backgound scale , center or full
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wezterm.