wezterm: added alias to zsh for wezterm ssh

This commit is contained in:
Tigor Hutasuhut 2024-08-14 13:50:08 +07:00
parent 3eb16c2ace
commit f92d4b5852
2 changed files with 16 additions and 1 deletions

View file

@ -20,6 +20,11 @@ in
''; '';
}; };
programs.zsh.initExtra = /*bash*/ ''
if [ -n "$WEZTERM_PANE" ]; then
alias ssh="wezterm ssh"
fi
'';
home.file.".config/wezterm" = { home.file.".config/wezterm" = {
source = ./.; source = ./.;

View file

@ -32,7 +32,7 @@ local process_icons = {
} }
local function get_current_working_dir(tab) local function get_current_working_dir(tab)
local current_dir = tab.active_pane and tab.active_pane.current_working_dir or { file_path = '' } local current_dir = tab.active_pane and tab.active_pane.current_working_dir() or { file_path = '' }
local HOME_DIR = os.getenv('HOME') local HOME_DIR = os.getenv('HOME')
return current_dir.file_path == HOME_DIR and '~' or string.gsub(current_dir.file_path, '(.*[/\\])(.*)', '%2') return current_dir.file_path == HOME_DIR and '~' or string.gsub(current_dir.file_path, '(.*[/\\])(.*)', '%2')
@ -51,6 +51,16 @@ local function get_process(tab)
return process_icons[process_name] or string.format('[%s]', process_name) return process_icons[process_name] or string.format('[%s]', process_name)
end end
wezterm.on('format-window-title', function(tab, tabs, panes, config)
local cwd = wezterm.format({
{ Text = get_current_working_dir(tab) },
})
local process = get_process(tab)
local title = process and string.format(' %s (%s) ', process, cwd) or ' [?] '
return title
end)
wezterm.on('format-tab-title', function(tab, tabs, panes, config, hover, max_width) wezterm.on('format-tab-title', function(tab, tabs, panes, config, hover, max_width)
local has_unseen_output = false local has_unseen_output = false
if not tab.is_active then if not tab.is_active then