split bashrc into separate files
parent
eb7b7a2456
commit
695355f0b0
155
dot_bashrc
155
dot_bashrc
|
@ -3,150 +3,29 @@
|
|||
|
||||
if [ "$PWD" != "$HOME" ] && [ "$PWD" -ef "$HOME" ] ; then cd ; fi
|
||||
if [ -d "/usr$HOME" ] ; then export HOME=/usr$HOME ; cd ; fi
|
||||
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi
|
||||
|
||||
[[ -f /etc/bashrc ]] && . /etc/bashrc || true
|
||||
[[ -f /etc/bash.bashrc ]] && . /etc/bash.bashrc || true
|
||||
[[ -f /etc/bash_completion ]] && . /etc/bash_completion || true
|
||||
[[ -r /etc/bash/bashrc ]] && . /etc/bash/bashrc || true
|
||||
[[ -r "/usr/local/share/bash-completion/bash_completion" ]] && . "/usr/local/share/bash-completion/bash_completion"
|
||||
if [[ -d "/usr/local/etc/bash_completion.d" ]] ; then
|
||||
for i in /usr/local/etc/bash_completion.d/*.sh ; do
|
||||
source "$i"
|
||||
done
|
||||
fi
|
||||
[[ -r "/usr/share/bash-completion/bash_completion" ]] && . "/usr/share/bash-completion/bash_completion"
|
||||
[[ -e $HOME/.local/bin/git-prompt.sh ]] && . $HOME/.local/bin/git-prompt.sh || true
|
||||
|
||||
alias dotfiles='git --git-dir=$HOME/dev/dotfiles.git/ --work-tree=$HOME'
|
||||
|
||||
EDITOR=vim; export EDITOR
|
||||
LESS="-R"; export LESS
|
||||
if which most > /dev/null 2>&1 ; then
|
||||
PAGER=most
|
||||
else
|
||||
PAGER=less
|
||||
fi
|
||||
export PAGER
|
||||
DELTA_PAGER=less; export DELTA_PAGER
|
||||
|
||||
GOPATH=$HOME/go; export GOPATH
|
||||
GOBIN=$GOPATH/bin; export GOBIN
|
||||
PATH=$HOME/.local/bin:$HOME/.cargo/bin:$GOBIN:${KREW_ROOT:-$HOME/.krew}/bin:$PATH
|
||||
|
||||
# don't put duplicate lines or lines starting with space in the history.
|
||||
# See bash(1) for more options
|
||||
HISTCONTROL=ignoreboth
|
||||
|
||||
# No locking on Ctrl-S
|
||||
stty -ixon
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
##
|
||||
## history: http://mywiki.wooledge.org/BashFAQ/088
|
||||
##
|
||||
|
||||
# Big history
|
||||
HISTFILESIZE=10000
|
||||
HISTSIZE=10000
|
||||
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
|
||||
|
||||
# history -a causes an immediate write of all new history lines
|
||||
# (instead of upon shell exit)
|
||||
PROMPT_COMMAND="history -a"
|
||||
|
||||
# histappend which causes all new history lines to be appended, and ensures
|
||||
# that multiple logins do not overwrite each other's history
|
||||
shopt -s histappend
|
||||
|
||||
if [[ ${EUID} == 0 ]] ; then
|
||||
PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
|
||||
else
|
||||
if type __git_ps1 > /dev/null 2>&1 ; then
|
||||
GIT_PS1_SHOWDIRTYSTATE=1
|
||||
GIT_PS1_SHOWSTASHSTATE=1
|
||||
GIT_PS1_SHOWUNTRACKEDFILES=1
|
||||
GIT_PS1_SHOWUPSTREAM="auto"
|
||||
GIT_PS1_SHOWCOLORHINTS=1
|
||||
GIT_PS1_HIDE_IF_PWD_IGNORED=1
|
||||
if [[ -n $SSH_CLIENT ]] ; then
|
||||
SSH_CHAR="📡"
|
||||
fi
|
||||
PROMPT_COMMAND='history -a; __git_ps1 "\[\033[01;32m\][\u@\h\[\033[01;34m\] ${SSH_CHAR}\w\[\033[01;32m\]]\[\033[00m\]" "\\\$ "'
|
||||
else
|
||||
PS1='\[\033[01;32m\][\u@\h\[\033[01;34m\] \w\[\033[01;32m\]]\[\033[00m\]\$ '
|
||||
for BASHRC in /etc/bashrc /etc/bash.bashrc /etc/bash/bashrc ; do
|
||||
if [ -f "$BASHRC" ] ; then
|
||||
. "$BASHRC"
|
||||
fi
|
||||
done
|
||||
unset BASHRC
|
||||
|
||||
EDITOR=nvim; export EDITOR
|
||||
|
||||
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
|
||||
then
|
||||
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
|
||||
fi
|
||||
|
||||
if which lsd > /dev/null 2>&1 ; then
|
||||
alias ls="lsd"
|
||||
else
|
||||
alias ls="ls --color=auto"
|
||||
fi
|
||||
alias grep='grep --colour=auto'
|
||||
alias egrep='egrep --colour=auto'
|
||||
alias fgrep='fgrep --colour=auto'
|
||||
|
||||
[[ "$(uname -s)" == "Darwin" ]] || xhost +local:root > /dev/null 2>&1 && true
|
||||
|
||||
complete -cf sudo
|
||||
|
||||
shopt -s expand_aliases
|
||||
|
||||
# ex - archive extractor
|
||||
# usage: ex <file>
|
||||
ex ()
|
||||
{
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*) echo "'$1' cannot be extracted via ex()" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
# change the title of the current window or tab
|
||||
title()
|
||||
{
|
||||
echo -ne "\033]0;$*\007"
|
||||
}
|
||||
|
||||
ssh()
|
||||
{
|
||||
echo -ne '\e[22t'
|
||||
/usr/bin/ssh "$@"
|
||||
echo -ne '\e[23t'
|
||||
}
|
||||
|
||||
su()
|
||||
{
|
||||
echo -ne '\e[22t'
|
||||
/bin/su "$@"
|
||||
echo -ne '\e[23t'
|
||||
}
|
||||
export PATH
|
||||
|
||||
# User specific aliases and functions
|
||||
if [ -d ~/.bashrc.d ]; then
|
||||
for rc in ~/.bashrc.d/*; do
|
||||
if [ -f "$rc" ]; then
|
||||
. "$rc"
|
||||
fi
|
||||
done
|
||||
for rc in ~/.bashrc.d/*; do
|
||||
if [ -f "$rc" ]; then
|
||||
. "$rc"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
unset rc
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
if which lsd > /dev/null 2>&1 ; then
|
||||
alias ls="lsd"
|
||||
else
|
||||
alias ls="ls --color=auto"
|
||||
fi
|
||||
alias grep='grep --colour=auto'
|
||||
alias egrep='egrep --colour=auto'
|
||||
alias fgrep='fgrep --colour=auto'
|
||||
|
||||
shopt -s expand_aliases
|
||||
|
||||
# ex - archive extractor
|
||||
# usage: ex <file>
|
||||
ex ()
|
||||
{
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1;;
|
||||
*.7z) 7z x $1 ;;
|
||||
*) echo "'$1' cannot be extracted via ex()" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
# change the title of the current window or tab
|
||||
title()
|
||||
{
|
||||
echo -ne "\033]0;$*\007"
|
||||
}
|
||||
|
||||
ssh()
|
||||
{
|
||||
echo -ne '\e[22t'
|
||||
/usr/bin/ssh "$@"
|
||||
echo -ne '\e[23t'
|
||||
}
|
||||
|
||||
su()
|
||||
{
|
||||
echo -ne '\e[22t'
|
||||
/bin/su "$@"
|
||||
echo -ne '\e[23t'
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
for rc in /etc/bash_completion /usr/local/share/bash-completion/bash_completion /usr/share/bash-completion/bash_completion ; do
|
||||
if [ -f "$rc" ] ; then
|
||||
. "$rc"
|
||||
fi
|
||||
done
|
||||
unset rc
|
||||
|
||||
if [ -d /usr/local/etc/bash_completion.d ] ; then
|
||||
for rc in /usr/local/etc/bash_completion.d/* ; do
|
||||
if [ -f "$rc" ] ; then
|
||||
. "$rc"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
unset rc
|
||||
|
||||
complete -cf sudo
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
# rustup shell setup
|
||||
# affix colons on either side of $PATH to simplify matching
|
||||
case ":${PATH}:" in
|
||||
*:"$HOME/.cargo/bin":*)
|
||||
;;
|
||||
*)
|
||||
# Prepending path in case a system-installed rustc needs to be overridden
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,3 @@
|
|||
GOPATH=$HOME/go; export GOPATH
|
||||
GOBIN=$GOPATH/bin; export GOBIN
|
||||
export PATH=$PATH:$GOBIN
|
|
@ -0,0 +1,20 @@
|
|||
# don't put duplicate lines or lines starting with space in the history.
|
||||
# See bash(1) for more options
|
||||
HISTCONTROL=ignoreboth
|
||||
|
||||
##
|
||||
## history: http://mywiki.wooledge.org/BashFAQ/088
|
||||
##
|
||||
|
||||
# Big history
|
||||
HISTFILESIZE=10000
|
||||
HISTSIZE=10000
|
||||
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
|
||||
|
||||
# history -a causes an immediate write of all new history lines
|
||||
# (instead of upon shell exit)
|
||||
PROMPT_COMMAND="history -a"
|
||||
|
||||
# histappend which causes all new history lines to be appended, and ensures
|
||||
# that multiple logins do not overwrite each other's history
|
||||
shopt -s histappend
|
|
@ -0,0 +1,8 @@
|
|||
LESS="-R"; export LESS
|
||||
if which most > /dev/null 2>&1 ; then
|
||||
PAGER=most
|
||||
else
|
||||
PAGER=less
|
||||
fi
|
||||
export PAGER
|
||||
DELTA_PAGER=less; export DELTA_PAGER
|
|
@ -0,0 +1,18 @@
|
|||
if [[ ${EUID} == 0 ]] ; then
|
||||
PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
|
||||
else
|
||||
if type __git_ps1 > /dev/null 2>&1 ; then
|
||||
GIT_PS1_SHOWDIRTYSTATE=1
|
||||
GIT_PS1_SHOWSTASHSTATE=1
|
||||
GIT_PS1_SHOWUNTRACKEDFILES=1
|
||||
GIT_PS1_SHOWUPSTREAM="auto"
|
||||
GIT_PS1_SHOWCOLORHINTS=1
|
||||
GIT_PS1_HIDE_IF_PWD_IGNORED=1
|
||||
if [[ -n $SSH_CLIENT ]] ; then
|
||||
SSH_CHAR="📡"
|
||||
fi
|
||||
PROMPT_COMMAND='history -a; __git_ps1 "\[\033[01;32m\][\u@\h\[\033[01;34m\] ${SSH_CHAR}\w\[\033[01;32m\]]\[\033[00m\]" "\\\$ "'
|
||||
else
|
||||
PS1='\[\033[01;32m\][\u@\h\[\033[01;34m\] \w\[\033[01;32m\]]\[\033[00m\]\$ '
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,8 @@
|
|||
# No locking on Ctrl-S
|
||||
stty -ixon
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi
|
|
@ -0,0 +1 @@
|
|||
[[ "$(uname -s)" == "Darwin" ]] || xhost +local:root > /dev/null 2>&1 && true
|
Loading…
Reference in New Issue