stuff
This commit is contained in:
parent
7b911a1990
commit
5ff197b53f
107
README.md
Normal file
107
README.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# repo.fish
|
||||||
|
|
||||||
|
A Fish shell plugin to simplify git repository management.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Clone repositories with a consistent directory structure
|
||||||
|
- Navigate to repositories quickly
|
||||||
|
- Create new git repositories
|
||||||
|
- Open repositories in your browser
|
||||||
|
- List all your repositories
|
||||||
|
- Customizable hooks for post-clone, post-goto, and post-new actions
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Install with [Fisher](https://github.com/jorgebucaran/fisher):
|
||||||
|
|
||||||
|
```fish
|
||||||
|
fisher install abs3ntdev/repo.fish
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Basic Commands
|
||||||
|
|
||||||
|
```fish
|
||||||
|
# Clone a repository
|
||||||
|
repo get github.com/user/repo
|
||||||
|
|
||||||
|
# Navigate to a repository
|
||||||
|
repo go github.com/user/repo
|
||||||
|
|
||||||
|
# Create a new repository
|
||||||
|
repo new github.com/user/myrepo
|
||||||
|
|
||||||
|
# Open current repository in browser
|
||||||
|
repo open
|
||||||
|
|
||||||
|
# Clone an AUR repository
|
||||||
|
repo aur package-name
|
||||||
|
|
||||||
|
# List all repositories
|
||||||
|
repo list
|
||||||
|
|
||||||
|
# Show help
|
||||||
|
repo help
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
By default, all repositories are stored in `~/repos`. You can change this by setting the `$REPO_BASE_DIR` variable in your `config.fish`:
|
||||||
|
|
||||||
|
```fish
|
||||||
|
set -gx REPO_BASE_DIR ~/path/to/repos
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Hooks
|
||||||
|
|
||||||
|
repo.fish provides three hooks that you can customize:
|
||||||
|
|
||||||
|
1. **Post-clone hook**: Runs after cloning a repository
|
||||||
|
2. **Post-goto hook**: Runs after navigating to a repository
|
||||||
|
3. **Post-new hook**: Runs after creating a new repository
|
||||||
|
|
||||||
|
To use hooks, define the following functions:
|
||||||
|
|
||||||
|
```fish
|
||||||
|
# Define a custom post-clone hook
|
||||||
|
function repo_post_clone
|
||||||
|
echo "Repository cloned to: $argv[1]"
|
||||||
|
# Your custom actions here
|
||||||
|
cd $argv[1]
|
||||||
|
# You can run additional commands like:
|
||||||
|
# npm install
|
||||||
|
# bundle install
|
||||||
|
# etc.
|
||||||
|
end
|
||||||
|
|
||||||
|
# Define a custom post-goto hook
|
||||||
|
function repo_post_goto
|
||||||
|
echo "Navigated to: $argv[1]"
|
||||||
|
# Your custom actions here
|
||||||
|
cd $argv[1]
|
||||||
|
# You can run additional commands like:
|
||||||
|
# git status
|
||||||
|
# ls -la
|
||||||
|
# etc.
|
||||||
|
end
|
||||||
|
|
||||||
|
# Define a custom post-new hook
|
||||||
|
function repo_post_new
|
||||||
|
echo "Created new repository at: $argv[1]"
|
||||||
|
# Your custom actions here
|
||||||
|
cd $argv[1]
|
||||||
|
# You can run additional commands like:
|
||||||
|
# touch README.md
|
||||||
|
# git add README.md
|
||||||
|
# git commit -m "Initial commit"
|
||||||
|
# etc.
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't define these functions, the default behavior is to change to the repository directory.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
@ -18,25 +18,4 @@ function __repo_needs_command
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function __repo_using_command
|
|
||||||
set -l cmd (commandline -opc)
|
|
||||||
if test (count $cmd) -gt 1
|
|
||||||
if test $argv[1] = $cmd[2]
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function __repo_list_repos
|
|
||||||
find "$REPO_BASE_DIR" -type d -name ".git" -printf "%h\n" 2>/dev/null | sed 's|.*/||; s/\./_/g'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Main command completions
|
|
||||||
complete -f -c repo -n __repo_needs_command -a '(__repo_commands)'
|
complete -f -c repo -n __repo_needs_command -a '(__repo_commands)'
|
||||||
|
|
||||||
# Repository completions
|
|
||||||
complete -f -c repo -n '__repo_using_command go; or __repo_using_command goto' -a '(__repo_list_repos)'
|
|
||||||
|
|
||||||
# Help option
|
|
||||||
complete -f -c repo -s h -l help -d 'Show help message'
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
function _repo_open
|
function _repo_open
|
||||||
set remote (git remote get-url origin)
|
set remote (git remote get-url origin)
|
||||||
set remote (string replace -r "git@" "https://" $remote)
|
set remote (string replace -r "git@" "https://" $remote)
|
||||||
set remote (string replace --max=1 ":" "/" $remote)
|
set remote (string replace -r "^https://([^/]+):" "https://\$1/" $remote)
|
||||||
|
|
||||||
if not command -q xdg-open
|
if not command -q xdg-open
|
||||||
echo "Error: xdg-open command not found"
|
echo "Error: xdg-open command not found"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if not xdg-open "$remote" 2>/dev/null
|
if not xdg-open "$remote" 2>/dev/null
|
||||||
echo "Error: Failed to open $remote"
|
echo "Error: Failed to open $remote"
|
||||||
return 1
|
return 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user