Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tmuxp support #87

Open
kohane27 opened this issue Mar 25, 2024 · 6 comments
Open

Add tmuxp support #87

kohane27 opened this issue Mar 25, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@kohane27
Copy link

kohane27 commented Mar 25, 2024

What would you like sesh to do?

Hello there! Thank you for creating sesh and the previous t-smart-tmux-session-manager!

I'm trying to migrate from t to sesh but facing the following problem.

Description

I'm using tmuxp to fzf find and load tmux sessions:

tmuxp load -d $(ls ~/.config/tmuxp | fzf)

The following is extracted from my modified t:

# check if selection is in is TMUXP
WORKSPACE_NAME=$($TMUXP_LS | grep "$RESULT")
if [ ! -z "$WORKSPACE_NAME" -a "$WORKSPACE_NAME" != " " ]; then
    $TMUXP_PATH load -d "$WORKSPACE_NAME" >/dev/null 2>&1
    tmux switch-client -t "$WORKSPACE_NAME"
    exit 0
fi

I'm hoping sesh would have the following:

  1. custom directories, i.e., sesh list ~/.config/tmuxp
  2. custom command, i.e., tmuxp load -d

Such that I can use the following:

sesh $CUSTOM_COMMAND "$(sesh list $CUSTOM_DIR | fzf-tmux -p 55%,60%)"

I understand that this may be out of project scope. I hacked on the original t because it's a bash script, but I'm not sure about golang.

Thank you again!

@kohane27 kohane27 added the enhancement New feature or request label Mar 25, 2024
@joshmedeski
Copy link
Owner

Hi @kohane27 thanks for the suggestion. I think integrating with tmuxp is possible.

Would you want non-tmuxp commands to still work (ex: listing existing sessions and attaching to current tmux sessions). If so, we'll probably need to adjust your suggestions to better work alongside existing functionality (rather than replacing it).

I've got some ideas but please clarify how you'd expect this to work alongside the current features sesh has to offer.

  • Would you want to list tmux sessions, zoxide results, and tmuxp configs at the same time?
  • Would you want to conditionally load tmuxp configs if the session already exists or there is not config file that matches the result?

@kohane27
Copy link
Author

kohane27 commented Mar 26, 2024

Thank you for considering this feature request! Initially, I thought it'd be out of project scope but then I saw the feature "clone a git repo and connect to it as a session" so I thought loading a tmux session would be appropriate enough.

Would you want to list tmux sessions, zoxide results, and tmuxp configs at the same time?

I think this would be best to leave it to the user to implement? What I current use indeed combine zoxide results and tmuxp configs:

2024-03-26-18-28-

  • If the entry is a tmuxp config (i.e., entries with just the tmuxp config name), it'd load that session and then switch to it.
  • If it's zoxide directory (entries starting with ~/ like the top 2 entries above), it'd create a session with that name and then switch to it.

Would you want to conditionally load tmuxp configs if the session already exists or there is not config file that matches the result?

Would you want non-tmuxp commands to still work (ex: listing existing sessions and attaching to current tmux sessions).

Thank you for considering these use cases! The following is what I have in mind:

COMMANDS:
   list, l      List sessions
   connect, cn  Connect to the given session
   load, load   Load a given session

Usage:

sesh load "$(sesh list -s | fzf-tmux -p 55%,60%)"

Note: -s for session

Given there are bind flags like --bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list)', it'd be easy enough to switch to other sesh lists, i.e., switching between sesh list -s or -t or -z on the fly is convenient enough.

Things to consider

There are many session managers like tmuxp, most notably tmuxinator:

tmuxinator start [project] -n [name] -p [project-config]

If sesh supports tmuxinator then it'd benefit more people. Maybe something similar to the following config?

[[session_path]]
# tmuxp
SESSION_DIR = "~/.config/tmuxp"
SESSION_MANAGER_COMMAND = "tmuxp load -d fzf-result-tmuxp-config-name"

# tmuxinator
SESSION_DIR = "~/.config/tmuxinator"
SESSION_MANAGER_COMMAND = "tmuxinator start --project-config=path/to/fzf/result/project.yaml"

Thank you again!

@joshmedeski
Copy link
Owner

I'd prefer to keep the connect command as-is, and extend it's functionality.

I think this approach could work:

[[session]]
name = "dotfiles"
path = "~/c/dotfiles"
tmuxp_config = "~/.config/tmuxp/dotfiles.yaml"

We could update the session config over time to offer different options, like tmuxinator as well.

[[session]]
name = "dotfiles"
path = "~/c/dotfiles"
tmuxinator_config = "~/.config/tmuxinator/dotfiles.yaml"

Do you like this approach? Then, sesh connect would be the same, and when you chose a path that matches a config, it would detect the config and run it.

@joshmedeski joshmedeski changed the title Add support for custom directory and custom command Add tmuxp support Mar 26, 2024
@joshmedeski joshmedeski moved this from Next to In Progress in OSS Development Mar 28, 2024
@kohane27
Copy link
Author

Hello @joshmedeski

Apologies for my late reply.

Thank you for the suggestion:) I think this approach of yours is cleaner!

I'm looking forward to testing when you have time to implement this feature. Thank you again!

@joshmedeski joshmedeski moved this from In Progress to Done in OSS Development Apr 16, 2024
@jonykalavera
Copy link

Quick workaround if you use .tmuxp.yaml files, at your sesh config dir:

$ cat sesh.toml
[default_session]
startup_script="~/.config/sesh/startup_script.sh"

$ cat startup_script.sh
#!/bin/bash
[[ -e ".tmuxp.yaml" ]] && tmuxp load -a .

@joshmedeski
Copy link
Owner

That works! For now I prefer being able to just call any arbitrary script. We can think more about adding specific integrations after v2 ships.

@joshmedeski joshmedeski moved this from Done to In Progress in OSS Development Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

3 participants