wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

Path not expanded in `cwd` field of `SpawnCommand`

Open joschka opened this issue 5 years ago • 3 comments

What Operating System(s) are you seeing this problem on?

Linux X11

WezTerm version

20211123-065748-f0f7110d

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

wezterm fails to recognize paths like ~/.config/wezterm or $HOME/.config in the cwd field of the SpawnCommand struct and falls back to using the home directory. An absolute path like /home/<USER>/.config/wezterm works, though.

To Reproduce

No response

Configuration

local wezterm = require 'wezterm'
return {
  keys = {
    {key = 'F12', mods = 'CTRL', action = wezterm.action{SpawnCommandInNewTab={cwd = '~/.config/wezterm', args = {'nvim', './wezterm.lua'}}}},
  }
}

Expected Behavior

expected: nvim opens ~/.config/wezterm/wezterm.lua

(actual: nvim opens ~/wezterm.lua)

Logs

No log entry.

Anything else?

No response

joschka avatar Nov 26 '21 19:11 joschka

This isn't a bug; ~ and environment expansion are not performed by lua.

You can use wezterm.home_dir to determine the home directory, and use something like this in your config:

local wezterm = require 'wezterm'
return {
  keys = {
    {key = 'F12', mods = 'CTRL', action = wezterm.action{SpawnCommandInNewTab={cwd = wezterm.home_dir .. '/.config/wezterm', args = {'nvim', './wezterm.lua'}}}},
  }
}

wez avatar Nov 26 '21 20:11 wez

Thank you for replying instantly. I didn't know this. Thank you very much for explaining. Your proposal works perfectly.

joschka avatar Nov 26 '21 20:11 joschka

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.

github-actions[bot] avatar Feb 04 '23 11:02 github-actions[bot]