Skip to content

Instantly share code, notes, and snippets.

@septicwolf818
Last active February 20, 2024 17:28
Show Gist options
  • Save septicwolf818/f059f7d8d2cfba318a4df8736664dccc to your computer and use it in GitHub Desktop.
Save septicwolf818/f059f7d8d2cfba318a4df8736664dccc to your computer and use it in GitHub Desktop.
My ZSH config
# You have to install ZSH shell first, then neofetch to make it work
autoload -Uz vcs_info
autoload -Uz compinit && compinit
autoload virtualenv
zstyle ':vcs_info:*' enable git svn
setopt PROMPT_SUBST
zstyle ':vcs_info:git*' formats "→ (%b) "
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ↠ '
}
precmd() {
vcs_info
PROMPT=$'\n'"%F{red}┌───%f%F{green}[%f%F{cyan} %n%F{red}@%f%F{cyan}%M%f %F{green}]%f %F{green}{%f %F{cyan}%T%f %F{green}}%f"$'\n'"%F{red}│%f"$'\n'"%F{red}└───%f%F{green}[%f %F{cyan}%~ %f%F{green}]%f %F{yellow}${vcs_info_msg_0_}%f%F{red}»%f "
PROMPT+='%F{magenta}$(virtualenv_info)%f'
}
merge_changes_from_master() {
local default_branch=${1:-master}
if [ "$default_branch" = "master" ]; then
print -P "\nℹ️ You can specify the %F{green}default branch%f as an argument when calling the function. Example: \n\n$ merge_changes_from_master %F{green}my_default_branch%f"
fi
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
print -P "\n✅ %F{green}Current directory is a Git repository.%f"
else
print -P "\n❌ %F{red}Current directory is not a Git repository.%f"
return
fi
current_branch=$(git branch | grep \* | sed 's/.* //')
print -P "\nℹ️ Current branch is %F{yellow}$current_branch%f\n"
print -Pn "❓ Do you want to proceed with merging changes from %F{green}$default_branch%f into %F{yellow}$current_branch%f?"
read -q "REPLY? (y/n) "
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
print -P "\nℹ️ Switching to %F{green}$default_branch%f\n"
git checkout "$default_branch"
print -P "\nℹ️ Pulling latest changes from origin %F{green}$default_branch%f\n"
git pull
print -P "\nℹ️ Switching back to %F{yellow}$current_branch%f\n"
git checkout "$current_branch"
print -P "\nℹ️ Merging changes from %F{green}$default_branch%f into %F{yellow}$current_branch%f\n"
git merge "$default_branch"
else
print -P "%F{red}\n❌ Merge operation aborted."
fi
}
clear && neofetch
alias ls="ls -laGh"
alias dir="ls"
alias nano="nano -lm"
alias edit="nano"
alias cls="clear"
alias update="brew update && brew upgrade"
alias neofetch="clear && neofetch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment