@@ -787,7 +787,6 @@ def generate_clone_directory_name(git_uri, custom_name = nil)
787787 return nil unless parsed
788788
789789 date_prefix = Time . now . strftime ( "%Y-%m-%d" )
790- host_part = parsed [ :host ] . split ( '.' ) . first # github.com -> github
791790 "#{ date_prefix } -#{ parsed [ :user ] } -#{ parsed [ :repo ] } "
792791 end
793792
@@ -796,9 +795,9 @@ def is_git_uri?(arg)
796795 arg . match? ( %r{^(https?://|git@)} ) || arg . include? ( 'github.com' ) || arg . include? ( 'gitlab.com' ) || arg . end_with? ( '.git' )
797796 end
798797
799- command = ARGV . shift
800-
801798 tries_path = extract_option_with_value! ( ARGV , '--path' ) || TrySelector ::TRY_PATH
799+
800+ command = ARGV . shift
802801 tries_path = File . expand_path ( tries_path )
803802
804803 # Test-only flags (undocumented; aid acceptance tests)
@@ -874,7 +873,15 @@ def cmd_init!(args, tries_path)
874873 bash_or_zsh_script = <<~SHELL
875874 try() {
876875 script_path='#{ script_path } '
877- cmd=$(/usr/bin/env ruby "$script_path" cd#{ path_arg } "$@" 2>/dev/tty)
876+ # Check if first argument is a known command
877+ case "$1" in
878+ clone|worktree|init)
879+ cmd=$(/usr/bin/env ruby "$script_path"#{ path_arg } "$@" 2>/dev/tty)
880+ ;;
881+ *)
882+ cmd=$(/usr/bin/env ruby "$script_path" cd#{ path_arg } "$@" 2>/dev/tty)
883+ ;;
884+ esac
878885 rc=$?
879886 if [ $rc -eq 0 ]; then
880887 case "$cmd" in
@@ -890,7 +897,13 @@ def cmd_init!(args, tries_path)
890897 fish_script = <<~SHELL
891898 function try
892899 set -l script_path "#{ script_path } "
893- set -l cmd (/usr/bin/env ruby "$script_path" cd#{ path_arg } $argv 2>/dev/tty | string collect)
900+ # Check if first argument is a known command
901+ switch $argv[1]
902+ case clone worktree init
903+ set -l cmd (/usr/bin/env ruby "$script_path"#{ path_arg } $argv 2>/dev/tty | string collect)
904+ case '*'
905+ set -l cmd (/usr/bin/env ruby "$script_path" cd#{ path_arg } $argv 2>/dev/tty | string collect)
906+ end
894907 set -l rc $status
895908 if test $rc -eq 0
896909 if string match -r ' && ' -- $cmd
0 commit comments