Created
February 13, 2021 07:04
-
-
Save thautwarm/eee92468d80621dce1dedc1ac1e1b24b to your computer and use it in GitHub Desktop.
bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PYTHONIOENCODING=utf8 | |
PROMPT_COMMAND="prompt-command" | |
# cache init | |
source activate base | |
if [[ -z "$my_pragma_once" ]]; then | |
export PATH="$HOME/.local/bin:$PATH" | |
source ~/.bashfiles/color.sh | |
source "$(scoop prefix git)\etc\profile.d\git-prompt.sh" | |
source /usr/share/bash-completion/bash_completion | |
export PATH=/c/Users/twshe/scoop/shims:$PATH | |
export my_pragma_once=1 | |
fi | |
HISTSIZE=100000 | |
HISTFILESIZE=200000 | |
HOME=~ | |
HISTFILE=~/.bashistory | |
bind 'set show-all-if-ambiguous on' | |
bind 'TAB:menu-complete' | |
bind '"\e[A": history-search-backward' | |
bind '"\e[B": history-search-forward' | |
bind '"\eOA": history-search-backward' | |
bind '"\eOB": history-search-forward' | |
function setup-bash-git(){ | |
git config --global core.autocrlf false | |
git config --global core.eol lf | |
git config --global core.editor "emacs" | |
git clone https://github.com/powerline/fonts.git --depth=1 | |
pacman -S make | |
# install | |
cd fonts | |
./install.sh | |
# git config --global core.editor "code --wait" | |
echo "Manually install Caskaydia Nerd fonts!" | |
} | |
STATUS_THEME_PROMPT_BAD="${bold_red}💢${reset_color}${normal} " | |
STATUS_THEME_PROMPT_OK="${bold_green}✅${reset_color}${normal} " | |
function mode-simple(){ | |
SIMPLE_PROMPT=1 | |
} | |
function mode-pretty(){ | |
SIMPLE_PROMPT= | |
} | |
function home-git(){ | |
git --work-tree=$HOME --git-dir=$HOME/.home $@ | |
} | |
function home-sync(){ | |
home-git pull origin master | |
home-git add -A | |
home-git commit -m "$(date -d 'now' '+%Y-%m-%d-%H:%M')" | |
home-git push origin master | |
} | |
function j(){ | |
cd "$(ajmp complete $@)" | |
} | |
function chpwd(){ | |
ajmp update "$PWD" | |
} | |
function prompt-command(){ | |
# record history | |
history -a | |
# apply chpwd | |
if [[ "$LASTWD" != "$PWD" ]]; then | |
chpwd | |
fi | |
LASTWD=$PWD | |
# set prompt status | |
if [ $? -eq 0 ] | |
then | |
my_status=" $STATUS_THEME_PROMPT_OK" | |
else | |
my_status=" $STATUS_THEME_PROMPT_BAD" | |
fi | |
# compute PS1 | |
local git_ps branch untracked dirty py | |
if [[ -z "$SIMPLE_PROMPT" ]]; then | |
if command -v python &> /dev/null | |
then | |
py=" ${blue} $(python --version | sed 's/[[:alpha:]|(|[:space:]]//g')${reset_color}" | |
fi | |
git rev-parse 2> /dev/null | |
if [[ $? -eq 0 ]]; then | |
branch=$(git branch 2>/dev/null | grep '*' | sed 's/* \(.*\)/\1/') | |
if [[ -n $(git status -s) ]]; then | |
untracked="${yellow}●${reset_color}" | |
fi | |
git diff --quiet || dirty="${red}✘${reset_color}" | |
git_ps=" ${cyan} (${branch}${reset_color}${dirty}${untracked}${cyan})${reset_color}" | |
fi | |
fi | |
PS1="\n${blue} \u ${reset_color}${yellow} \D{}${reset_color}${git_ps}${py}${my_status}${blue} \w\n ${normal}" | |
PS2=" " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment