joshmedeski / sesh

Smart session manager for the terminal
MIT License
579 stars 34 forks source link

Recommeded "T" script fails #132

Closed dirad closed 2 months ago

dirad commented 3 months ago

What happened?

After adding recommended configs in my tmux.conf :

bind-key "T" run-shell "sesh connect \"$(
    sesh list | fzf-tmux -p 55%,60% \
        --no-sort --ansi --border-label ' sesh ' --prompt '⚑  ' \
        --header '  ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
        --bind 'tab:down,btab:up' \
        --bind 'ctrl-a:change-prompt(⚑  )+reload(sesh list)' \
        --bind 'ctrl-t:change-prompt(πŸͺŸ  )+reload(sesh list -t)' \
        --bind 'ctrl-g:change-prompt(βš™οΈ  )+reload(sesh list -c)' \
        --bind 'ctrl-x:change-prompt(πŸ“  )+reload(sesh list -z)' \
        --bind 'ctrl-f:change-prompt(πŸ”Ž  )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
        --bind 'ctrl-d:execute(tmux kill-session -t {})+change-prompt(⚑  )+reload(sesh list)'
)\""

using the hotkey gives the session selection screen, however empty [using sesh list does list out all sessions]. After exiting [esc], im left with a displayed, in full screen, in select mode

'sesh connect "$(

Version

sesh version dev

Relevant log output

No response

Reviewed

joshmedeski commented 2 months ago

I wasn't able to recreate this issue. Does the same thing happen when you press ctrl-c instead of esc?

dirad commented 2 months ago

yes it does.

dirad commented 2 months ago

Wow this is super weird...

To troubleshoot, I made a new tmux config folder, copied over only the tmux.conf, and restarted the server. Tried the hotkey, and it worked fine. I went back to the original folder, essentially the only difference is the plugins folder, so i was about to start toggling. However the hotkey started working....... what.?

joshmedeski commented 2 months ago

A few users have ran into issues when trying to adopt sesh while the tmux server was already running.

Thankfully Sesh v2 is coming soon and will have more exhaustive tooling for debugging.

johmsalas commented 3 days ago

I still see this issue, seems like run-shell runs on a different mode:

This tmux config: bind-key t run-shell "echo \"$PATH\"" prints out:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

which is not the PATH of my user

I'm wondering if it tries to run in non interactive and skips files like .bashrc or .profile

btw, I'm using MacOs, Nix and I can confirm it used to work and stopped working at some point

joshmedeski commented 3 days ago

Thanks for the update @johmsalas

johmsalas commented 3 days ago

I think I understand the issue now. When tmux is started manuall in the terminal, it reads the env and that's the context for tmux. I recently modified it to be started automatically using Wezterm (and this is when sesh stopped working), using this in my wezterm config:

config.default_prog = { "/opt/homebrew/bin/tmux", "new", "-A" } I still don't know why, but Wezterm does not provide the environment to tmux, and that env provided during the startup is the one used for run-shell.

My solution is: config.default_prog = { "bash", "-l", "-c", "/usr/bin/env /opt/homebrew/bin/tmux attach || /usr/bin/env /opt/homebrew/bin/tmux" }

My solution will probably evolve, and its specific for Wezterm, but at least it gives you an idea, the trick is to pass the envs on tmux startup Hope it helps people facing the same issue.

and thanks @joshmedeski for such a great DX improvement and your concise, wonderful and to the point videos