Skip to content

Conversation

@alienxp03
Copy link
Contributor

@alienxp03 alienxp03 commented Jul 31, 2025

Add dir_length configuration option

Fixes: #272

This PR adds a new dir_length configuration option that allows users to control how many directory components are included in session names.

What's Changed

  • New config option: dir_length in sesh.toml (defaults to 1 for backwards compatibility)

Problem

sesh only uses the current directory name, which won't work if you have the same directory name with different parent. In the example below, both will only refer to the same one child session:

- /Users/user/project1/child → child
- /Users/user/project2/child → child

New changes

With dir_length = 1 (default):
- /Users/user/projects/sesh → sesh

With dir_length = 2:
- /Users/user/projects/sesh → projects/sesh

With dir_length = 3:
- /Users/user/projects/sesh → user/projects/sesh

Configuration

# ~/.config/sesh/sesh.toml
dir_length = 2  # Uses last 2 directories. (Optional, empty config will defaults to 1)

Would love feedback on these changes. Thanks!

@joshmedeski
Copy link
Owner

Sorry for not responding to this sooner, can you fix the merge conflicts on this?

I'm happy to look it over this week and help get it merged, I know people will appreciate this feature!

@alienxp03 alienxp03 force-pushed the feature/dir-length branch 3 times, most recently from be00682 to 6131288 Compare October 3, 2025 05:05
User can use dir_length config for the session name. Defaults to 1 if
empty

dir_length = 2
@alienxp03
Copy link
Contributor Author

No worries. I have rebased the branch. Do let know your thoughts!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new dir_length configuration option that allows users to control how many directory components are included in tmux session names, addressing the issue where sessions with identically named directories in different parent paths would collide.

Key Changes:

  • Added DirLength field to model.Config with default value of 1 for backwards compatibility
  • Updated dirName() function to support multi-component directory paths based on configuration
  • Modified NewNamer() to accept config parameter and propagate it throughout the codebase

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
model/config.go Added DirLength field to Config struct
namer/dir.go Implemented logic to extract N directory components from paths
namer/dir_test.go Added comprehensive test coverage for directory naming with various lengths
namer/namer.go Updated constructor to accept and store config
namer/git.go Modified to use dirName() for repository naming
namer/git_bare.go Modified to use dirName() for bare repository naming
namer/root_git.go Simplified error handling and switched to dirName()
configurator/configurator.go Added validation to ensure DirLength defaults to 1 if not set
seshcli/root_command.go Updated NewNamer() call to pass config
namer/namer_test.go Updated all test cases to include config parameter
namer/git_test.go Updated all test cases to include config parameter
go.mod Moved lipgloss dependency from direct to indirect
README.md Added documentation for the new configuration option

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks for your patience on this.

@joshmedeski joshmedeski merged commit f575a54 into joshmedeski:main Nov 6, 2025
4 checks passed
@alienxp03 alienxp03 deleted the feature/dir-length branch November 6, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opens the wrong directory when child directory names are identical across different parents.

2 participants