dots/.bashrc

69 lines
1.3 KiB
Bash
Raw Normal View History

2020-04-07 22:24:30 +02:00
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# load aliases dynamically
[ -f "$HOME/.aliasrc" ] && source "$HOME/.aliasrc"
2020-05-08 18:08:53 +02:00
# add ~/.bin to PATH
export PATH=~/.bin:$PATH
2020-05-07 02:10:20 +02:00
# prompt
bold=$(tput bold)
reset=$(tput sgr0)
2020-04-08 21:22:00 +02:00
2020-05-07 02:10:20 +02:00
get_branch_name() {
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|| git rev-parse --short HEAD 2>/dev/null \
|| echo 'some branch'
}
2020-04-07 22:24:30 +02:00
2020-05-07 02:10:20 +02:00
get_git_info() {
git rev-parse --is-inside-work-tree &>/dev/null || return
2020-05-07 20:12:19 +02:00
echo -e "${1}$(get_branch_name)"
2020-05-07 02:10:20 +02:00
}
2020-05-07 20:12:19 +02:00
PS1='\[\033[38;5;244m\]\[${bold}\]$(get_git_info && echo "\n")\[${reset}\]\u \W ❭ '
2020-04-07 22:24:30 +02:00
# history
export HISTCONTROL=ignoreboth
2020-08-18 18:20:58 +02:00
export HISTSIZE=500000
2020-04-07 22:24:30 +02:00
2020-05-07 02:10:20 +02:00
# source fuzzy finder
source /usr/share/fzf/*.bash
2020-05-07 03:39:04 +02:00
# vim-style keybindings
2020-05-08 02:20:56 +02:00
export EDITOR='vim'
2020-05-07 03:39:04 +02:00
set -o vi
bind '"jj":"\e"'
2020-05-08 19:54:20 +02:00
export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -t -g ""'
export FZF_COMPLETION_OPTS='-x'
2020-05-13 19:05:27 +02:00
# nvm
lazy_load_nvm() {
unset -f nvm node npm npx
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
}
nvm() {
lazy_load_nvm
nvm $@
}
node() {
lazy_load_nvm
node $@
}
npm() {
lazy_load_nvm
npm $@
}
npx() {
lazy_load_nvm
npx $@
}