Created
January 10, 2025 00:30
auto cd after git clone <url>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function auto_cd_xdotool --on-event fish_prompt | |
if test $status -eq 0 | |
if string match -q "mkdir*" $history[1] | |
set -l splits (string split -n ' ' $history[1]) | |
for i in $splits[-1..2] | |
if not string match -q -- "-*" $i | |
xdotool type --delay 100 "cd $i" | |
return | |
end | |
end | |
end | |
if string match -q "git clone*" $history[1] | |
set -l splits (string split -n ' ' $history[1]) | |
for i in $splits[-1..3] | |
if string match -q "https://*" $i | |
set -l split1 (string split -n '/' $i) | |
xdotool type --delay 100 "cd $split1[-1]" | |
return | |
end | |
if string match -q "git@*.git" $i | |
set -l last (string split '/' $i)[-1] | |
set -l dir_name (string sub --end -4 $last) | |
xdotool type --delay 100 "cd $dir_name" | |
return | |
end | |
if not string match -q -- "-*" $i | |
xdotool type --delay 100 "cd $i" | |
return | |
end | |
end | |
end | |
end | |
end |
Cons
- not work in ssh
- not work in wayland
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this fn in ~/.config/fish/config.fish