Compare commits
12 commits
8a340366bf
...
6690c470e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6690c470e3 | ||
| 3d1adc0c12 | |||
|
|
1f7ead6134 | ||
|
|
f2b09cee54 | ||
|
|
f1ab8e79db | ||
| 82201ce6b3 | |||
| 0f17558dfe | |||
| 07e35d8b8c | |||
|
|
f8bad2700b | ||
|
|
742b1d5a5c | ||
|
|
ba46ba95d9 | ||
|
|
672701d1f7 |
5 changed files with 38 additions and 13 deletions
|
|
@ -66,6 +66,7 @@ It was inspired by [[https://wiki.ros.org/wstool][wstool]], [[https://github.com
|
|||
! - Local changes
|
||||
+ - Staged changes
|
||||
- - File removed
|
||||
» - File renamed
|
||||
= - Both modified
|
||||
⇕ - Diverged from upstream
|
||||
⇡ - Ahead upstream
|
||||
|
|
@ -84,6 +85,6 @@ It was inspired by [[https://wiki.ros.org/wstool][wstool]], [[https://github.com
|
|||
: git remote set-head origin -a
|
||||
|
||||
Or set it manually to any branch with:
|
||||
: git remote set-head origin <branch_name>
|
||||
: git remote set-head origin <branch_name>
|
||||
|
||||
The number of additional local branches which are neither checked out, nor the =origin/HEAD= branch, is appended at the end of the branch output, e.g. =(+8)=.
|
||||
|
|
|
|||
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1694760568,
|
||||
"narHash": "sha256-3G07BiXrp2YQKxdcdms22MUx6spc6A++MSePtatCYuI=",
|
||||
"lastModified": 1709101946,
|
||||
"narHash": "sha256-TsySgcWm/GlbYdL3AEva49ceeI2BdPQ7muwfYNr1fwo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "46688f8eb5cd6f1298d873d4d2b9cf245e09e88e",
|
||||
"rev": "d53c2037394da6fe98decca417fc8fda64bf2443",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
24
gis
24
gis
|
|
@ -52,7 +52,7 @@ while (( "$#" )); do
|
|||
exit 0
|
||||
;;
|
||||
-*)
|
||||
error "Unsupported option ${text_bold}$1${text_bold}"
|
||||
error "Unsupported option ${text_bold}$1${text_reset}"
|
||||
;;
|
||||
fetch)
|
||||
fetch=true
|
||||
|
|
@ -120,7 +120,7 @@ if [ "$fetch" == true ]; then
|
|||
repository_name=$(basename "$dir")
|
||||
|
||||
# Fetch all Git repositories in background
|
||||
git fetch --prune --all 1> /dev/null 2> >(trap 'kill $! 2> /dev/null' INT TERM; sed "s/^/${text_bold}${text_blue}${repository_name}${text_reset} /" >&2) &
|
||||
git fetch --prune --all 1> /dev/null 2> >(trap 'kill $! 2> /dev/null' INT TERM; sed "s/^/${text_bold}${text_blue}${repository_name}${text_reset} /") &
|
||||
fetch_pids+=("$!")
|
||||
done
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ if [ "$pull" == true ]; then
|
|||
# Get repository name
|
||||
repository_name=$(basename "$dir")
|
||||
|
||||
git pull 1> /dev/null 2> >(trap 'kill $! 2> /dev/null' INT TERM; sed "s/^/${text_bold}${text_magenta}${repository_name}${text_reset} /" >&2) &
|
||||
git pull > >(trap 'kill $! 2> /dev/null' INT TERM; sed "s/^/${text_bold}${text_magenta}${repository_name}${text_reset} /") &
|
||||
pull_pids+=("$!")
|
||||
done
|
||||
|
||||
|
|
@ -197,8 +197,12 @@ for dir in "${git_dirs[@]}"; do
|
|||
|
||||
# Get status
|
||||
remote_status_keys=""
|
||||
has_upstream=true
|
||||
while read -r status; do
|
||||
if [[ "$status" =~ ^\#\#.*\[(.*)\] ]]; then
|
||||
if [[ "$status" =~ ^\#\#\ (.*) ]] && [ "$(git remote | wc -l)" -gt 0 ]; then
|
||||
[[ "${BASH_REMATCH[1]}" != *"..."* ]] && has_upstream=false
|
||||
fi
|
||||
if [[ "$status" =~ ^\#\#.*\ \[(.*)\] ]]; then
|
||||
[[ "${BASH_REMATCH[1]}" == *"ahead"* ]] && [[ "${BASH_REMATCH[1]}" == *"behind"* ]] && remote_status_keys="⇕" && continue
|
||||
[[ "${BASH_REMATCH[1]}" == *"ahead"* ]] && remote_status_keys="⇡" && continue
|
||||
[[ "${BASH_REMATCH[1]}" == *"behind"* ]] && remote_status_keys="⇣" && continue
|
||||
|
|
@ -215,6 +219,7 @@ for dir in "${git_dirs[@]}"; do
|
|||
status_keys="${status_keys//D/-}"
|
||||
status_keys="${status_keys//M/!}"
|
||||
status_keys="${status_keys//U/=}"
|
||||
status_keys="${status_keys//R/»}"
|
||||
|
||||
# Update all status keys
|
||||
all_status_keys="${all_status_keys}${status_keys}"
|
||||
|
|
@ -229,11 +234,17 @@ for dir in "${git_dirs[@]}"; do
|
|||
output="${output}${repository_name};${status_keys}"
|
||||
|
||||
# Construct branch output
|
||||
if [ "$current_branch" = "$origin_head" ]; then
|
||||
if [ "$current_branch" == "$origin_head" ]; then
|
||||
output="${output};${text_bold}${current_branch}${text_reset}"
|
||||
else
|
||||
output="${output};${text_bold}${text_yellow}${current_branch}${text_reset}"
|
||||
fi
|
||||
if [ "$has_upstream" == false ]; then
|
||||
output="${output} ${text_blue}[no upstream]${text_reset}"
|
||||
fi
|
||||
if [ "$current_branch" != "$origin_head" ]; then
|
||||
num_additional_branches=$(( num_additional_branches - 1 ))
|
||||
output="${output};${text_bold}${text_yellow}${current_branch}${text_reset} (${origin_head}${text_reset})"
|
||||
output="${output} (${origin_head}${text_reset})"
|
||||
fi
|
||||
if [[ $num_additional_branches -gt 0 ]]; then
|
||||
output="${output} (+${num_additional_branches})"
|
||||
|
|
@ -251,6 +262,7 @@ if [[ "$all_status_keys" ]]; then
|
|||
[[ "$all_status_keys" == *"!"* ]] && echo " ${text_bold}${text_red}!${text_reset} - Local changes"
|
||||
[[ "$all_status_keys" == *"+"* ]] && echo " ${text_bold}${text_red}+${text_reset} - Staged changes"
|
||||
[[ "$all_status_keys" == *"-"* ]] && echo " ${text_bold}${text_red}-${text_reset} - File removed"
|
||||
[[ "$all_status_keys" == *"»"* ]] && echo " ${text_bold}${text_red}»${text_reset} - File renamed"
|
||||
[[ "$all_status_keys" == *"="* ]] && echo " ${text_bold}${text_red}=${text_reset} - Both modified"
|
||||
[[ "$all_status_keys" == *"⇕"* ]] && echo " ${text_bold}${text_red}⇕${text_reset} - Diverged from upstream"
|
||||
[[ "$all_status_keys" == *"⇡"* ]] && echo " ${text_bold}${text_red}⇡${text_reset} - Ahead upstream"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Check 'column' dependency
|
||||
if ! command -v column &> /dev/null; then
|
||||
echo "Command 'column' not available on the system, please make sure all dependencies are fulfilled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Adds $1 to ~/.bashrc if not already present
|
||||
function _add_to_config {
|
||||
if ! grep "$1" ~/.bashrc > /dev/null; then
|
||||
|
|
|
|||
12
install.zsh
12
install.zsh
|
|
@ -1,5 +1,11 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# Check 'column' dependency
|
||||
if ! command -v column &> /dev/null; then
|
||||
echo "Command 'column' not available on the system, please make sure all dependencies are fulfilled."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Adds $1 to ~/.zshrc if not already present
|
||||
function _add_to_config {
|
||||
if ! grep "$1" ~/.zshrc > /dev/null; then
|
||||
|
|
@ -10,9 +16,9 @@ function _add_to_config {
|
|||
# Link files
|
||||
basedir="$(dirname "$(realpath "$0")")"
|
||||
mkdir -p ~/.local/{bin,share/bash-completion/completions}
|
||||
ln -frs "${basedir}/gis" ~/.local/bin/gis
|
||||
ln -fs "${basedir}/gis" ~/.local/bin/gis
|
||||
echo "Created link '~/.local/bin/gis'"
|
||||
ln -frs "${basedir}/gis_completion.bash" ~/.local/share/bash-completion/completions/gis
|
||||
ln -fs "${basedir}/gis_completion.bash" ~/.local/share/bash-completion/completions/gis
|
||||
echo "Created link '~/.local/share/bash-completion/completions/gis'"
|
||||
|
||||
# Modify config
|
||||
|
|
@ -20,7 +26,7 @@ touch ~/.zshrc
|
|||
_add_to_config "export PATH=\$PATH:${HOME}/.local/bin"
|
||||
_add_to_config "autoload -U +X compinit && compinit"
|
||||
_add_to_config "autoload -U +X bashcompinit && bashcompinit"
|
||||
_add_to_config "source /home/${USER}/.local/share/bash-completion/completions/gis"
|
||||
_add_to_config "source ${HOME}/.local/share/bash-completion/completions/gis"
|
||||
echo "Updated '~/.zshrc'"
|
||||
|
||||
echo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue