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

Support for killing previous session after connecting to a new session #134

Open
GravityShark0 opened this issue Jul 19, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@GravityShark0
Copy link

GravityShark0 commented Jul 19, 2024

What would you like sesh to do?

Sometimes I use sesh like cd/zoxide but automatically creates a new tmux session at the same time.
So I would usually go like

# this is just in simple command form but i usually interact with this in fzf

# go to my project directory
sesh connect ~/Code

# create a new project like
mkdir new-project

# and then connect to it
sesh connect ~/Code/new-project

but then I would be left with a session that will just clutter my list of sessions and I have to remove later.

I also like to use it after I know I'm done with a session as a bitty bit faster way of killing one and also I get to select the next session I want to view.

So I have made a workaround via a script.

#!/bin/sh
# t is just this script without the kill-session
[ ! -n "$TMUX" ] && {
	t
	return
}
prev_session=$(tmux display-message -p '#S')
out=$(
	sesh list -i -H | fzf-tmux -e --ansi -p 80%,80% \
		--no-sort --border-label ' sesh relinquish ' --prompt '' \
		--header '  ^a all ^t sessions ^f find ^k kill selected session' \
		--bind 'tab:down,btab:up' \
		--bind 'ctrl-a:change-prompt(⚡ )+reload(sesh list -iH)' \
		--bind 'ctrl-t:change-prompt(  )+reload(sesh list -it)' \
		--bind 'ctrl-f:change-prompt(  )+reload(fd -td --absolute-path | sed -E "s|$HOME|~|g; s|.*|\x1b[36m \x1b[0m&\x1b[0m|")' \
		--bind 'ctrl-k:execute(tmux kill-session -t $(echo {} | cut -c 5-))+change-prompt(⚡ )+reload(sesh list -i -H)'
)

sesh connect "$out" || return
if [ "$out" != "" ]; then
	tmux kill-session -t "$prev_session"
fi

So I would use Ctrl-F to show all the relative files and connect to them

this type of workflow also influenced this #133 issue because without using --absolute-path It will just break

But I would very much appreciate an option in sesh connect and maybe in sesh clone too so I wouldn't have to use this weird script

OPTIONS:
   --abandon -a       Only works while within a session, after connecting to a different session, kill previous session.
@GravityShark0 GravityShark0 added the enhancement New feature or request label Jul 19, 2024
@joshmedeski
Copy link
Owner

Ooo, I really like this idea. I think I can play around with it more next month.

Thanks for the suggestion!

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: Backlog
Development

No branches or pull requests

2 participants