mirror of
https://github.com/chenasraf/dotfiles.git
synced 2026-05-18 01:29:06 +00:00
feat: update git open commands
This commit is contained in:
@@ -249,13 +249,13 @@ customCommands:
|
||||
title: 'Choose an action'
|
||||
key: 'action'
|
||||
options:
|
||||
- name: 'Pull Requests'
|
||||
description: 'Open pull requests'
|
||||
value: 'pull_requests'
|
||||
- name: 'Pipelines'
|
||||
description: 'Open pipelines'
|
||||
value: 'pipelines'
|
||||
command: 'git {{.Form.action}} {{.SelectedLocalBranch.Name}}'
|
||||
- name: 'Open Project'
|
||||
value: 'project'
|
||||
- name: 'Open Pull Requests'
|
||||
value: 'prs'
|
||||
- name: 'Open CI'
|
||||
value: 'ci'
|
||||
command: 'git open {{.Form.action}} {{.SelectedLocalBranch.Name}}'
|
||||
loadingText: 'Opening...'
|
||||
services: {}
|
||||
notARepository: prompt
|
||||
|
||||
20
install.sh
20
install.sh
@@ -68,12 +68,6 @@ git config --global pull.rebase true
|
||||
git config --global core.excludesfile "~/.config/.gitignore"
|
||||
# git config --global core.untrackedCache true
|
||||
# git config --global core.fsmonitor true
|
||||
git config --global alias.unchanged "update-index --assume-unchanged"
|
||||
git config --global alias.changed "update-index --no-assume-unchanged"
|
||||
git config --global alias.show-unchanged "!git ls-files -v | sed -e 's/^[a-z] //p; d'"
|
||||
git config --global alias.prs "!source $DOTFILES/plugins/git_custom_commands.plugin.zsh prs"
|
||||
git config --global alias.pipelines "!source $DOTFILES/plugins/git_custom_commands.plugin.zsh pipelines"
|
||||
git config --global alias.actions "!source $DOTFILES/plugins/git_custom_commands.plugin.zsh pipelines"
|
||||
git config --global rerere.enabled true
|
||||
git config --global gpg.format "ssh"
|
||||
git config --global gpg.ssh.allowedSignersFile "~/.ssh/allowed_signers"
|
||||
@@ -83,6 +77,20 @@ git config --global fetch.writeCommitGraph true
|
||||
git config --global log.showSignature true
|
||||
git config --global core.excludesfile ~/.config/.gitignore
|
||||
|
||||
# ================================================================================================
|
||||
# Aliases/Custom commands
|
||||
# ================================================================================================
|
||||
|
||||
# Change status
|
||||
git config --global alias.unchanged "update-index --assume-unchanged"
|
||||
git config --global alias.changed "update-index --no-assume-unchanged"
|
||||
git config --global alias.show-unchanged "!git ls-files -v | sed -e 's/^[a-z] //p; d'"
|
||||
|
||||
# Open
|
||||
git config --global alias.open "!source $DOTFILES/plugins/git_custom_commands.plugin.zsh open"
|
||||
git config --global alias.pr "!source $DOTFILES/plugins/git_custom_commands.plugin.zsh prs"
|
||||
git config --global alias.ci "!source $DOTFILES/plugins/git_custom_commands.plugin.zsh ci"
|
||||
|
||||
if [[ ! -f $(which delta) ]]; then
|
||||
if ask "Install delta?"; then
|
||||
echo_yellow "Installing delta..."
|
||||
|
||||
@@ -38,6 +38,38 @@ git_get_remote_type() {
|
||||
return 0
|
||||
}
|
||||
|
||||
git_open_project() {
|
||||
remote=$(git_get_remote)
|
||||
if [[ -z $remote ]]; then
|
||||
echo "No remote found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
remote_type=$(git_get_remote_type)
|
||||
if [[ -z $remote_type ]]; then
|
||||
echo "Unknown remote type for $remote"
|
||||
return 1
|
||||
fi
|
||||
|
||||
case $remote_type in
|
||||
github)
|
||||
open "https://github.com/$remote"
|
||||
;;
|
||||
gitlab)
|
||||
open "https://gitlab.com/$remote"
|
||||
;;
|
||||
bitbucket)
|
||||
open "https://bitbucket.org/$remote"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown remote type: $remote_type"
|
||||
return 2
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
git_open_pr_list() {
|
||||
# branch=$1
|
||||
# if [[ -z $branch ]]; then
|
||||
@@ -52,7 +84,7 @@ git_open_pr_list() {
|
||||
|
||||
remote_type=$(git_get_remote_type)
|
||||
if [[ -z $remote_type ]]; then
|
||||
echo "Unknown remote type"
|
||||
echo "Unknown remote type for $remote"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -94,7 +126,7 @@ git_open_pipelines() {
|
||||
|
||||
remote_type=$(git_get_remote_type)
|
||||
if [[ -z $remote_type ]]; then
|
||||
echo "Unknown remote type"
|
||||
echo "Unknown remote type for $remote"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -117,13 +149,21 @@ git_open_pipelines() {
|
||||
return 0
|
||||
}
|
||||
|
||||
if [[ ! -z $1 ]]; then
|
||||
git_open() {
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Usage: git open <command>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
project|repo|open)
|
||||
git_open_project
|
||||
;;
|
||||
pr|prs)
|
||||
shift
|
||||
git_open_pr_list $@
|
||||
;;
|
||||
actions|pipelines)
|
||||
actions|pipelines|ci)
|
||||
shift
|
||||
git_open_pipelines $@
|
||||
;;
|
||||
@@ -132,4 +172,11 @@ if [[ ! -z $1 ]]; then
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
open)
|
||||
shift
|
||||
git_open $@
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user