Skip to content

Instantly share code, notes, and snippets.

@IDK9911
Last active January 6, 2023 16:19
Show Gist options
  • Save IDK9911/ec425bd83d3d2839c9884650a0dd1e8b to your computer and use it in GitHub Desktop.
Save IDK9911/ec425bd83d3d2839c9884650a0dd1e8b to your computer and use it in GitHub Desktop.
How to setup a terminal that has a RPROMPT that informs about (git branch) we are.
eval "$(/opt/homebrew/bin/brew shellenv)"
#MINE
autoload -U colors && colors
RPROMPT="%{$fg[cyan]%} %c %w%{$reset_color%}"
#PROMPT is at zlogin
precmd(){
#Mine
check=$(/Users/kazimsyed/Desktop/Sharing_stuff/funcs/kaz.sh `pwd`)
if [[ $check != "128" ]]
then
RPROMPT="%{$fg[yellow]%} $check %{$fg[white]%} %c %w%{$reset_color%}"
else
RPROMPT="%{$fg[cyan]%} %c %w%{$reset_color%}"
fi
}
#Here the precmd runs the code whenever you run the command in the shell.
#This will run the script /path/to/script.sh every time you enter a command in the shell.
#Also u can put this command either in ur ~/.zlogin or ~/.zprofile in ur zsh shell
kazimsyed@kazims-MacBook-Air ~/Desktop/Sharing_stuff/funcs
% cat kaz.sh main funcs Fri 6
x=$1
y=$(dirname $x)
z=$(dirname $y)
if [[ -d $x/.git ]] || [[ -d $y/.git ]] || [[ -d $z/.git ]]
then
git branch | gawk '/*/{print $2}';
fi
exit "128";
@IDK9911
Copy link
Author

IDK9911 commented Jan 6, 2023

Note: to refresh ur zsh shell use the zsh-l command on the terminal that way you won't have to close the terminal again and again.

@IDK9911
Copy link
Author

IDK9911 commented Jan 6, 2023

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment