8000 support for more colour options? · Issue #23 · sinclairtarget/git-who · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

support for more colour options? #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
snoblenet opened this issue Mar 26, 2025 · 2 comments
Open

support for more colour options? #23

snoblenet opened this issue Mar 26, 2025 · 2 comments

Comments

@snoblenet
Copy link

Thanks for git-who.

I have this script:

#!/bin/zsh

DIR="${1:-$PWD}"

if [[ -z "$(get_top_level $DIR)" ]]; then
  echo "$DIR is not in a Git repository"
else
  BRANCHES="$(git -C $DIR branch --all --sort=committerdate | sed 's/* //g' | sed 's/  //g' | grep --invert-match remote)"
  BRANCH="$(echo $BRANCHES | fzf --prompt 'Select branch:')"

  BASENAME="$DIR:t"
  PARENT="$DIR:h"

  SUBDIRECTORIES="$(fd --type directory --max-depth 1 --base-directory $PWD)"
  DIRECTORIES=".\n$SUBDIRECTORIES"
  DIRECTORY="$(echo $DIRECTORIES | fzf --prompt 'Select directory:')"

  echo "$fg_bold[yellow]$fg_bold[green]  $BRANCH"
  echo "$fg_bold[yellow]$fg_bold[green]  $PWD/$DIRECTORY" | sed 's/\/Users\//~/g' | sed 's/\/\.$//g'
  echo "$reset_color"

  git who $BRANCH -l -- $DIRECTORY
fi

It produces this result:

Image

It looks pretty good, but it also makes me wonder whether you have considered adding options for colourising the borders, columns, headers, etc...?

@snoblenet
Copy link
Author

(I just fixed sed 's/\/Users\//~/g' in my own copy of the script but I won't post a new screenshot.)

@snoblenet
Copy link
Author

A better version, in case anyone finds it handy

#!/bin/zsh

DIR="${1:-$PWD}"
TOP_LEVEL="$(get_top_level $DIR)"

if [[ -z "$TOP_LEVEL" ]]; then
  echo "$DIR is not in a Git repository"
else
  BRANCHES="$(git -C $TOP_LEVEL branch --all --sort=committerdate | sed 's/* //g' | sed 's/  //g' | grep --invert-match remote)"
  BRANCH="$(echo $BRANCHES | fzf --prompt 'Select branch:')"

  BASENAME="$TOP_LEVEL:t"
  PARENT="$TOP_LEVEL:h"

  SUBDIRECTORIES="$(fd --type directory --max-depth 2 --base-directory $TOP_LEVEL)"
  DIRECTORIES=".\n$SUBDIRECTORIES"
  DIRECTORY="$(echo $DIRECTORIES | fzf --prompt 'Select directory:')"

  echo "$fg_bold[yellow]$fg_bold[green]  $BRANCH"
  echo "$fg_bold[yellow]$fg_bold[green]  $TOP_LEVEL/$DIRECTORY" | sed 's/\/Users\/steven/~/g' | sed 's/\/\.$//g'
  echo "$reset_color"

  if [[ "$DIRECTORY" == "." ]]; then
    git -C "$TOP_LEVEL" who $BRANCH -l
  else
    git -C "$TOP_LEVEL" who $BRANCH -l -- $DIRECTORY
  fi
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0