Compare commits

...

12 commits

Author SHA1 Message Date
Denis Lehmann
6690c470e3 check column dependency 2024-09-19 10:18:17 +02:00
3d1adc0c12
Merge pull request #8 from ConstantConstantin/update/renamed
add symbol for renamed files
2024-08-08 13:49:24 +00:00
ConstantConstantin
1f7ead6134 add symbol for renamed files 2024-08-08 15:48:06 +02:00
Denis Lehmann
f2b09cee54 fix error formatting 2024-04-18 12:58:05 +02:00
Denis Lehmann
f1ab8e79db beautify missing upstream hint 2024-03-19 17:59:00 +01:00
82201ce6b3 update flake inputs 2024-02-28 22:37:04 +01:00
0f17558dfe show missing upstream branches 2024-02-28 22:34:39 +01:00
07e35d8b8c update flake inputs 2023-12-12 22:37:28 +01:00
Denis Lehmann
f8bad2700b echo pull information 2023-11-02 11:48:56 +01:00
Deleh
742b1d5a5c
Merge pull request #6 from benmaidel/osx
osx compatibility
2023-10-22 12:46:47 +02:00
Benjamin Maidel
ba46ba95d9 use /Users/ben env variable instead of /home/ben 2023-10-20 20:46:19 +02:00
Benjamin Maidel
672701d1f7 remove -r (relative link) from ln commands 2023-10-20 20:32:22 +02:00
5 changed files with 38 additions and 13 deletions

View file

@ -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
View file

@ -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
View file

@ -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"

View file

@ -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

View file

@ -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