diff --git a/README.md b/README.md index 12a965c..48e60f4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Ever find yourself with 50 directories named `test`, `test2`, `new-test`, `actua **try** is here for your beautifully chaotic mind. -# What it does +# What it does ![Fuzzy Search Demo](assets/try-fuzzy-search-demo.gif) @@ -162,6 +162,7 @@ Supported git URI formats: - `git@github.com:user/repo.git` (SSH GitHub) - `https://gitlab.com/user/repo.git` (GitLab) - `git@host.com:user/repo.git` (SSH other hosts) +- `ssh://git@host.com:port/user/repo.git` (SSH other hosts with custom port) The `.git` suffix is automatically removed from URLs when generating directory names. @@ -199,9 +200,9 @@ nix run github:tobi/try init ~/my-tries ```nix { inputs.try.url = "github:tobi/try"; - + imports = [ inputs.try.homeManagerModules.default ]; - + programs.try = { enable = true; path = "~/experiments"; # optional, defaults to ~/src/tries diff --git a/spec/command_line.md b/spec/command_line.md index 52066c2..21b5031 100644 --- a/spec/command_line.md +++ b/spec/command_line.md @@ -77,6 +77,9 @@ try https://github.com/tobi/try.git try clone git@github.com:tobi/try.git # SSH URL also works: 2025-11-30-tobi-try + +try clone ssh://git@yourgitserver:port/user/repo.git +# SSH URL with custom port also works: 2025-11-30-user-repo ``` ### worktree diff --git a/spec/tests/test_32_git_uri.sh b/spec/tests/test_32_git_uri.sh index 6356928..5bd8852 100644 --- a/spec/tests/test_32_git_uri.sh +++ b/spec/tests/test_32_git_uri.sh @@ -36,6 +36,14 @@ else fail "SSH gitlab.com should parse user/repo" "user-sshrepo" "$output" "git_uri" fi +# Test: Other SSH host with custom port +output=$(try_run --path="$TEST_TRIES" exec clone ssh://git@git_host:port/user/customsshrepo.git 2>&1) +if echo "$output" | grep -q "user-customsshrepo"; then + pass +else + fail "SSH git_host:port should parse user/customsshrepo" "user-customsshrepo" "$output" "git_uri" +fi + # Test: Unparseable URI produces error output=$(try_run --path="$TEST_TRIES" exec clone not-a-valid-uri 2>&1) exit_code=$? diff --git a/try.rb b/try.rb index d966f80..ccf6d6c 100755 --- a/try.rb +++ b/try.rb @@ -1057,6 +1057,10 @@ def parse_git_uri(uri) # git@host:user/repo host, user, repo = $1, $2, $3 return { user: user, repo: repo, host: host } + elsif uri.match(%r{^ssh://git@([^/]+)/([^/]+)/([^/]+)}) + # ssh://git@host:port/user/repo + host, user, repo = $1, $2, $3 + return { user: user, repo: repo, host: host } else return nil end