Add git aliases; Install zsh and oh-my-zsh

This commit is contained in:
Raoul Snyman 2020-12-13 23:25:39 -07:00
parent ef2445d2bd
commit 5f6c54e867
Signed by: raoul
GPG Key ID: F55BCED79626AE9C
2 changed files with 79 additions and 3 deletions

View File

@ -2,12 +2,49 @@
# This script sets up the configuration from this repository
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
APT=`command -v apt`
DNF=`command -v dnf`
# Link Neovim config
function check_or_install {
CMD=`command -v $1`
PKG=$2
if [[ -z "$CMD" ]]; then
if [[ -n "$APT" ]]; then
sudo apt install -y $PKG
elif [[ -n "$DNF" ]]; then
sudo dnf install -y $PKG
fi
fi
}
# Set up Neovim
check_or_install nvim "neovim python3-neovim"
mkdir -p ~/.config
cd ~/.config
ln -s $DIR/nvim
# Install VimPlug
curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Set up Git
check_or_install git git
git config --global alias.co checkout
git config --global alias.ci "commit -a"
git config --global alias.st status
git config --global alias.br "checkout -b"
git config --global alias.rv "reset --hard HEAD"
git config --global alias.pum "pull upstream master"
git config --global alias.pom "push origin master"
git config --global alias.rbm "rebase master"
git config --global alias.last "log -1 HEAD"
git config --global alias.unstage "reset HEAD --"
git config --global alias.uncommit "reset --soft HEAD^"
git config --global alias.changelog "!_() { t=$(git describe --abbrev=0 --tags); git log ${t}..HEAD --no-merges --pretty=format:'* %s'; }; _"
git config --global pull.rebase false
# Set up ZSH
check_or_install zsh zsh
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
cd ~/.oh-my-zsh/custom
ln -s $DIR/zsh/themes
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="raoul"/' ~/.zshrc

View File

@ -0,0 +1,39 @@
# -*- sh -*- vim:set ft=sh ai et sw=4 sts=4:
# It might be bash like, but I can't have my co-workers knowing I use zsh
PROMPT='%{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info)$(hg_prompt_info)%(!.#.$) '
PROMPT_PREFIX=" %{$fg[magenta]%}"
PROMPT_SUFFIX="%{$reset_color%} "
PROMPT_CLEAN=""
PROMPT_DIRTY=" %{$fg[yellow]%}✗%{$reset_color%}"
# git
ZSH_THEME_GIT_PROMPT_PREFIX=$PROMPT_PREFIX
ZSH_THEME_GIT_PROMPT_SUFFIX=$PROMPT_SUFFIX
ZSH_THEME_GIT_PROMPT_DIRTY=$PROMPT_DIRTY
ZSH_THEME_GIT_PROMPT_CLEAN=$PROMPT_CLEAN
# hg
ZSH_THEME_HG_PROMPT_PREFIX=$PROMPT_PREFIX
ZSH_THEME_HG_PROMPT_SUFFIX=$PROMPT_SUFFIX
ZSH_THEME_HG_PROMPT_DIRTY=$PROMPT_DIRTY
ZSH_THEME_HG_PROMPT_CLEAN=$PROMPT_CLEAN
# bzr
ZSH_THEME_BZR_PROMPT_PREFIX=$PROMPT_PREFIX
ZSH_THEME_BZR_PROMPT_SUFFIX=$PROMPT_SUFFIX
ZSH_THEME_BZR_PROMPT_DIRTY=$PROMPT_DIRTY
ZSH_THEME_BZR_PROMPT_CLEAN=$PROMPT_CLEAN
function bzr_prompt_info() {
BZR_CB=`bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print $1}'`
if [ -n "$BZR_CB" ]; then
BZR_DIRTY=""
if [[ -n `bzr status` ]]; then
BZR_DIRTY=$ZSH_THEME_BZR_PROMPT_DIRTY
else
BZR_DIRTY=$ZSH_THEME_BZR_PROMPT_CLEAN
fi
echo "$ZSH_THEME_BZR_PROMPT_PREFIX$BZR_CB$BZR_DIRTY$ZSH_THEME_BZR_PROMPT_SUFFIX"
fi
}