add git thing

master
XWasHere 2023-10-23 13:17:22 -04:00
parent 28545fe7e5
commit 88161e5a85
Signed by: XWasHere
GPG Key ID: 042F8BFA1B0EF93B
2 changed files with 97 additions and 13 deletions

40
.zshrc
View File

@ -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%(!.#.$) ';

70
zsh/prompt_miniline_setup Normal file
View File

@ -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} ';
}