Closed jacksongoode closed 11 months ago
I had the same issue and I tried to create zsh and wezterm config files as minimum as possible to replicate the issue and simplify the debugging.
Unfortunately I don't know the answer but hope these files help.
Indeed, the right directory shows up if you create a pane (or tab), destroy it, and create it again.
wezterm.lua:
local wezterm = require 'wezterm'
local config = {}
config.keys = {
{
key = 'd',
mods = 'CMD',
action = wezterm.action.SplitHorizontal { domain =
'CurrentPaneDomain' },
},
{ key = 't', mods = 'CMD', action = wezterm.action.SpawnTab 'DefaultDomain' },
}
return config
zsh file
a) if I uncomment those 'return' in set-title-precmd() and set-title-preexec(), I get the right behavior
b) If I comment install_zsh_plugin "zsh-autosuggestions"
, it also works fine
function install_zsh_plugin(){
GITHUBZSH=https://github.com/zsh-users
plugname=$1
PLUGDIR=$HOME/.zsh/$1
[[ ! -d "$PLUGDIR" ]] && \
git clone "$GITHUBZSH/$plugname" $PLUGDIR
source $PLUGDIR/$plugname.zsh
}
function set-title-precmd() {
# return
printf "\e]2;%s\a" "mytitle"
}
function set-title-preexec() {
# return
printf "\e]2;%s\a" "mytitle"
}
install_zsh_plugin "zsh-autosuggestions"
autoload -Uz add-zsh-hook
add-zsh-hook preexec set-title-preexec
add-zsh-hook precmd set-title-precmd
@marconetto Thank you for the reply I'll try out your method!
Hi @jacksongoode it would be nice indeed if you could check if these modifications solve the issue. At least we would help narrow down a simple case to replicate the problem.
Hmm, so I don't have anything changing the tab title. My zimfw config does enable the https://github.com/zsh-users/zsh-autosuggestions plugin. But disabling it doesn't appear to fix the issue from my end. Getting rid of zim as the module manager does resolve this, so I'm guessing some module is being loaded. Here is my .zimrc (which should nearly be the default):
# Start configuration added by Zim install {{{
#
# This is not sourced during shell startup, and it's only used to configure the
# zimfw plugin manager.
#
#
# Modules
#
# Sets sane Zsh built-in environment options.
zmodule environment
# Provides handy git aliases and functions.
zmodule git
# Applies correct bindkeys for input events.
zmodule input
# Sets a custom terminal title.
zmodule termtitle
# Utility aliases and functions. Adds colour to ls, grep and less.
zmodule utility
# z jump
zmodule https://github.com/agkozak/zsh-z
# pyenv
zmodule pvenv
# Ruby
zmodule ruby
#
# Prompt
#
# Current dir
zmodule prompt-pwd
# Exposes to prompts how long the last command took to execute, used by asciiship.
zmodule duration-info
# Exposes git repository status information to prompts, used by asciiship.
zmodule git-info
# Theme
zmodule bira
#
# Completion
#
# Additional completion definitions for Zsh.
zmodule zsh-users/zsh-completions --fpath src
# Enables and configures smart and extensive tab completion.
# completion must be sourced after all modules that add completion definitions.
zmodule completion
#
# Modules that must be initialized last
#
# Fish-like syntax highlighting for Zsh.
# zsh-users/zsh-syntax-highlighting must be sourced after completion
zmodule zsh-users/zsh-syntax-highlighting
# Fish-like history search (up arrow) for Zsh.
# zsh-users/zsh-history-substring-search must be sourced after zsh-users/zsh-syntax-highlighting
zmodule zsh-users/zsh-history-substring-search
# Fish-like autosuggestions for Zsh.
zmodule zsh-users/zsh-autosuggestions
# }}} End configuration added by Zim install
Ah @marconetto I just realized that:
# Sets a custom terminal title.
zmodule termtitle
Is causing the conflict which probably has the same interaction as your title formatting does. Disabling this resolves the issue for me. This is set by default in zimrc.
great @jacksongoode!
perhaps wezterm makes use of the current title to define the current work directory when opening a new tab/pane... and changing the title via zsh is generating the problem. Let's see if wezterm core developers have any input here.
Hi @jacksongoode
I was doing more research on the issue and I found this related one:
https://github.com/wez/wezterm/discussions/3718
The snippet code showed by Tyler solved the issue for me without making any removal of my current zsh configuration: https://github.com/wez/wezterm/discussions/3718#discussioncomment-6032441
Additional references from that issue: https://wezfurlong.org/wezterm/config/lua/config/default_cwd.html https://github.com/yenaras/zsh/blob/main/osc7_escape_sequence
And: https://wezfurlong.org/wezterm/shell-integration.html
So, it seems it is not a bug of wezterm. I guess you may close the issue.
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.
What Operating System(s) are you seeing this problem on?
macOS
Which Wayland compositor or X11 Window manager(s) are you using?
No response
WezTerm version
wezterm 20230712-072601-f4abf8fd
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
No, and I'll explain why below
Describe the bug
Opening a new tab/pane from a directory does not open that tab in the same working directory. However, opening a new tab from the original pane a second time does open the second tab instance in the working directory.
However, calling
set-working-directory
before launching a new tab does carry the directory over.To Reproduce
Configuration
Here is my zshrc:
Expected Behavior
New directory should match previous
Logs
No response
Anything else?
No response