From 88161e5a8578ded301028bfaf51e3a50acdffbf7 Mon Sep 17 00:00:00 2001 From: XWasHere Date: Mon, 23 Oct 2023 13:17:22 -0400 Subject: [PATCH] add git thing --- .zshrc | 40 ++++++++++++++-------- zsh/prompt_miniline_setup | 70 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 zsh/prompt_miniline_setup diff --git a/.zshrc b/.zshrc index 19550c4..a296b59 100644 --- a/.zshrc +++ b/.zshrc @@ -1,19 +1,28 @@ -# wow proper history stuff -HISTFILE=~/.histfile -HISTSIZE=1000 -SAVEHIST=1000 +fpath=("$(dirname "$(realpath ~/.zshrc)")/zsh" $fpath); + +# completions +autoload -Uz compinit +compinit; + +# wow history stuff +HISTFILE=~/.histfile; +HISTSIZE=1000; +SAVEHIST=1000; # what the fuck are any of these -setopt extendedglob -setopt nomatch -setopt notify +setopt extendedglob; +setopt nomatch; +setopt notify; # who the fuck would want either of these -unsetopt autocd -unsetopt beep +unsetopt autocd; +unsetopt beep; -# i dont even know what this does lmao -bindkey -v +# add vim keybinds +bindkey -v; + +# add other keybinds +bindkey '^[[3~' delete-char; # c++ compiler export CXX=clang++; @@ -27,9 +36,14 @@ alias m="make"; alias gaa="git add -A"; alias gc="git commit -S -a"; alias gcm="git commit -S -a -m"; +alias gs="git status"; alias cls="clear" alias ls="exa" # line -PS1=$'\u256d\u2500 %F{cyan}%n@%m%F{white} | %F{red}%/%f > \n\u2570%(!.#.$) '; -PS2=$'%{\x1b[A\u2502 \x1b[B\x1b[G%0G%}\u2570%(!.#.$) '; +autoload -U promptinit; +promptinit; +#prompt miniline; + +#PS1=$'\u256d\u2500 %F{cyan}%n@%m%F{white} | %F{red}%/%f > \n\u2570%(!.#.$) '; +#PS2=$'%{\x1b[A\u2502 \x1b[B\x1b[G%0G%}\u2570%(!.#.$) '; diff --git a/zsh/prompt_miniline_setup b/zsh/prompt_miniline_setup new file mode 100644 index 0000000..d085a94 --- /dev/null +++ b/zsh/prompt_miniline_setup @@ -0,0 +1,70 @@ +# vim: set filetype=zsh : + +function () { + MINILINE_NERD_FONTS=true; + MINILINE_GLYPH_GIT="|\\"; + MINILINE_GLYPH_BRANCH="|/"; + MINILINE_GLYPH_COMMIT="@-"; + + MINILINE_INCLUDE_VCS=true; + + MINILINE_COLOR_COMMIT="yellow"; #"#FFA500"; + MINILINE_COLOR_BRANCH="cyan"; + + if $MINILINE_NERD_FONTS; then + MINILINE_GLYPH_GIT=$'\ue702'; + MINILINE_GLYPH_BRANCH=$'\ue725'; + MINILINE_GLYPH_COMMIT=$'\ue729'; + fi + + prompt_opts=(cr percent subst); + + function ps_vcs() { + ps_vcs=""; + + ! $MINILINE_INCLUDE_VCS && return; + + # search for git dir + local found=false; + local dir="$(realpath "$(pwd)")"; + while [[ "$dir" != "/" ]]; do + if [[ -d "$dir/.git" ]]; then + found=true; + break; + fi; + + dir="$(realpath "$dir/..")"; + done; + + # handle git repo + if $found; then + local git_dir="$dir/.git"; + + # read current head + local head_type="commit"; + local head="$(<"$git_dir/HEAD")"; + local branch; + if [[ "$head" =~ 'ref: (.*)' ]]; then + head="${match[1]}"; + head_type="branch"; + + [[ "$head" =~ 'refs/heads/(.*)' ]]; + branch="${match[1]}"; + fi; + + if [[ "$head_type" == "commit" ]]; then + [[ "$head" =~ '(........).*' ]]; # this might not be a valid commit but whos going to use a repo with smth that large + ps_vcs=" | $MINILINE_GLYPH_COMMIT %F{$MINILINE_COLOR_COMMIT}${match[1]}%F{white}"; + elif [[ "$head_type" == "branch" ]]; then + ps_vcs=" | $MINILINE_GLYPH_BRANCH %F{$MINILINE_COLOR_COMMIT}HEAD%F{$MINILINE_COLOR_BRANCH}@$branch%F{white}"; + fi; + fi; + } + + function precmd() { + ps_vcs; + } + + PS1=$'\u256d\u2500 %F{cyan}%n@%m%F{white} | %F{red}%/%f${ps_vcs} > \n\u2570%(!.#.$)%F{white} '; + PS2=$'%{\x1b[A\u2502 \x1b[B\x1b[G%0G%}\u2570%(!.#.$)%F{white} '; +}