Reorganize bash config
parent
393e2c5db5
commit
e1f55bed1a
28
.bashrc
28
.bashrc
|
@ -4,40 +4,18 @@
|
||||||
|
|
||||||
source /etc/os-release
|
source /etc/os-release
|
||||||
|
|
||||||
# Functions {{{
|
# Editor & prompt configuration
|
||||||
[ -f "$HOME/.bashrc.d/editor" ] && source "$HOME/.bashrc.d/editor"
|
[ -f "$HOME/.bashrc.d/editor" ] && source "$HOME/.bashrc.d/editor"
|
||||||
# }}}
|
[ -f "$HOME/.bashrc.d/prompt" ] && source "$HOME/.bashrc.d/prompt"
|
||||||
|
|
||||||
# Aliases {{{
|
|
||||||
# Load aliases dynamically
|
# Load aliases dynamically
|
||||||
[ -f "$HOME/.bash_aliases/all" ] && source "$HOME/.bash_aliases/all"
|
[ -f "$HOME/.bash_aliases/all" ] && source "$HOME/.bash_aliases/all"
|
||||||
[ -f "$HOME/.bash_aliases/hosts/$HOSTNAME" ] && source "$HOME/.bash_aliases/hosts/$HOSTNAME"
|
[ -f "$HOME/.bash_aliases/hosts/$HOSTNAME" ] && source "$HOME/.bash_aliases/hosts/$HOSTNAME"
|
||||||
[ -f "$HOME/.bash_aliases/private" ] && source "$HOME/.bash_aliases/private"
|
[ -f "$HOME/.bash_aliases/private" ] && source "$HOME/.bash_aliases/private"
|
||||||
# }}}
|
|
||||||
|
|
||||||
# Dynamic configuration {{{
|
# Host-specific and private configurations
|
||||||
[ -f "$HOME/.bashrc.d/hosts/$HOSTNAME" ] && source "$HOME/.bashrc.d/hosts/$HOSTNAME"
|
[ -f "$HOME/.bashrc.d/hosts/$HOSTNAME" ] && source "$HOME/.bashrc.d/hosts/$HOSTNAME"
|
||||||
[ -f "$HOME/.bashrc.d/private" ] && source "$HOME/.bashrc.d/private"
|
[ -f "$HOME/.bashrc.d/private" ] && source "$HOME/.bashrc.d/private"
|
||||||
# }}}
|
|
||||||
|
|
||||||
# Prompt {{{
|
|
||||||
get_branch_name() {
|
|
||||||
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|
|
||||||
|| git rev-parse --short HEAD 2>/dev/null \
|
|
||||||
|| echo 'some branch'
|
|
||||||
}
|
|
||||||
get_git_info() {
|
|
||||||
git rev-parse --is-inside-work-tree &>/dev/null || return
|
|
||||||
echo -e " $(get_branch_name)"
|
|
||||||
}
|
|
||||||
|
|
||||||
PS1="\u \w ❭\[$(tput sgr0)\] "
|
|
||||||
|
|
||||||
# Ellipsis when deep in directory
|
|
||||||
export PROMPT_DIRTRIM=2
|
|
||||||
|
|
||||||
export PS1
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# Path {{{
|
# Path {{{
|
||||||
# Add ~/.bin to PATH
|
# Add ~/.bin to PATH
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# vim: set ft=bash :
|
||||||
|
get_branch_name() {
|
||||||
|
git symbolic-ref --quiet --short HEAD 2>/dev/null \
|
||||||
|
|| git rev-parse --short HEAD 2>/dev/null \
|
||||||
|
|| echo 'some branch'
|
||||||
|
}
|
||||||
|
get_git_info() {
|
||||||
|
git rev-parse --is-inside-work-tree &>/dev/null || return
|
||||||
|
echo -e "($(get_branch_name))"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $SSH_CONNECTION ]]; then
|
||||||
|
PS1='\[\033[01;31m\]\u@\h\[\033[00m\] $(get_git_info)\W❭\[$(tput sgr0)\] '
|
||||||
|
else
|
||||||
|
PS1='\u $(get_git_info)\W❭\[$(tput sgr0)\] '
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ellipsis when deep in directory
|
||||||
|
export PROMPT_DIRTRIM=2
|
||||||
|
export PS1
|
Loading…
Reference in New Issue