This commit is contained in:
abs3nt 2025-03-03 18:08:28 -08:00
parent 31659e91b0
commit 26e932f445
Signed by: abs3nt
GPG Key ID: A7BD96A8BAB04C09
11 changed files with 0 additions and 194 deletions

@ -1,23 +0,0 @@
function repo_clone
if test -z "$argv[2]"
echo "Error: Repository path is required"
return 1
end
set repo_prefix $argv[1]
set cleaned (clean_repo_path "$argv[2]")
set output_path "$REPO_BASE_DIR/$cleaned"
set suffix ".git"
set clean_path (string replace -r "$suffix\$" "" "$output_path")
mkdir -p "$clean_path"
if test ! -d "$clean_path/.git"
set repourl (string replace "/" ":" "$repo_prefix@$cleaned" -r)
echo "Cloning $repourl to $clean_path..."
git clone "$repourl" "$clean_path"
else
echo "Repository already exists: $clean_path"
end
post_repo_clone "$clean_path"
end

@ -1,14 +0,0 @@
function clean_repo_path
set stripped $argv[1]
set stripped (string replace -r "^http://" "" $stripped)
set stripped (string replace -r "^https://" "" $stripped)
set stripped (string replace -r "^git@" "" $stripped)
set stripped (string replace -r "^ssh://" "" $stripped)
set stripped (string replace -r "^aur@" "" $stripped)
set stripped (string replace -r ":" "/" $stripped)
if not string match -q "*/*" $stripped
set stripped "github.com/$stripped"
end
echo "$stripped"
end

@ -1,11 +0,0 @@
function repo_goto
if test -z "$argv[1]"
echo "Error: Repository path is required"
return 1
end
set cleaned (clean_repo_path "$argv[1]")
set output_path "$REPO_BASE_DIR/$cleaned"
set suffix ".git"
post_repo_goto (string replace -r "$suffix\$" "" "$output_path")
end

@ -1,16 +0,0 @@
function repo_help
echo "Usage: repo <command> <repository>"
echo ""
echo "Commands:"
echo " get Clone a repository to the repos directory"
echo " open Open the current repository in the browser"
echo " aur Clone an AUR repository"
echo " list List all repositories"
echo " go|goto Navigate to a repository"
echo " new|create Create a new repository"
echo " help Show this help message"
echo ""
echo "Examples:"
echo " repo get github.com/user/repo"
echo " repo open"
end

@ -1,11 +0,0 @@
function post_repo_clone
cd "$argv[1]"
end
function post_repo_goto
cd "$argv[1]"
end
function post_repo_new
cd "$argv[1]"
end

@ -1,6 +0,0 @@
function list_repos
find "$REPO_BASE_DIR" -type d -name ".git" | while read -l git_dir
set parent_dir (dirname "$git_dir")
string replace -r '.*/' '' "$parent_dir" | string replace -a '.' '_'
end
end

@ -1,19 +0,0 @@
function repo_new
if test -z "$argv[1]"
echo "Error: Repository path is required"
return 1
end
set cleaned (clean_repo_path "$argv[1]")
set output_path "$REPO_BASE_DIR/$cleaned"
set clean_path (string replace -r "\.git\$" "" "$output_path")
mkdir -p "$clean_path"
if test ! -d "$clean_path/.git"
git init "$clean_path"
else
echo "Repository already exists: $clean_path"
end
post_repo_new "$clean_path"
end

@ -1,6 +0,0 @@
function repo_open
set remote (git remote get-url origin)
set remote (string replace "git@" "https://" $remote)
set remote (string replace ":" "/" $remote)
xdg-open "$remote"
end

@ -1,25 +0,0 @@
function repo
set cmd $argv[1]
set arg $argv[2]
switch "$cmd"
case 'get'
repo_clone "git" "$arg"
case 'aur'
repo_clone "aur" "$arg"
case 'open'
repo_open
case 'list'
list_repos
case 'go' 'goto'
repo_goto "$arg"
case 'new' 'create'
repo_new "$arg"
case 'help' '-h' '-help' '--help'
repo_help
case '*'
echo "Unknown command: $cmd"
repo_help
return 1
end
end

@ -16,20 +16,6 @@ sheldon add repo-manager --github abs3ntdev/repo-manager
zinit light abs3ntdev/repo-manager zinit light abs3ntdev/repo-manager
``` ```
### Fish
- Fisher
```
fisher install abs3ntdev/repo-manager
```
- Oh My Fish
```
omf install abs3ntdev/repo-manager
```
## usage ## usage
``` ```
@ -88,41 +74,6 @@ post_repo_new() {
} }
``` ```
#### Fish
Hooks are configured by overriding the functions provided in the plugin in hooks.fish
The default hooks are:
```fish
function post_repo_clone
cd "$argv[1]"
end
function post_repo_goto
cd "$argv[1]"
end
function post_repo_new
cd "$argv[1]"
end
```
You can override these in your config.fish or in a file sourced by your config.fish to do whatever you want. Example:
```fish
function post_repo_clone
code "$argv[1]"
end
function post_repo_goto
nvim "$argv[1]"
end
function post_repo_new
some_script "$argv[1]"
end
```
### base directory ### base directory
#### ZSH #### ZSH
@ -132,11 +83,3 @@ The base directory is set via ENV. The default is $HOME/repos. You can change th
```zsh ```zsh
export REPO_BASE_DIR="whatever/you/want" export REPO_BASE_DIR="whatever/you/want"
``` ```
#### Fish
The base directory is set via ENV. The default is $HOME/repos. You can change this by adding the following to your config.fish:
```fish
set -g REPO_BASE_DIR "whatever/you/want"
```

@ -1,6 +0,0 @@
set -q REPO_BASE_DIR; or set -g REPO_BASE_DIR "$HOME/repos"
set functions_dir (status dirname)/functions
for script in $functions_dir/*.fish
source $script
end