Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -162,6 +162,7 @@ Supported git URI formats:
- `[email protected]:user/repo.git` (SSH GitHub)
- `https://gitlab.com/user/repo.git` (GitLab)
- `[email protected]:user/repo.git` (SSH other hosts)
- `ssh://[email protected]:port/user/repo.git` (SSH other hosts with custom port)

The `.git` suffix is automatically removed from URLs when generating directory names.

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions spec/command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ try https://github.com/tobi/try.git

try clone [email protected]: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
Expand Down
8 changes: 8 additions & 0 deletions spec/tests/test_32_git_uri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?
Expand Down
4 changes: 4 additions & 0 deletions try.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down