You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

185 lines
4.8 KiB
Plaintext

4 years ago
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
[[ "$(whoami)" = "root" ]] && return
[[ -z "$FUNCNEST" ]] && export FUNCNEST=100 # limits recursive functions, see 'man bash'
# disable history
HISTFILE=/dev/null
4 years ago
## Use the up and down arrow keys for finding a command in history
## (you can write some initial letters of the command first).
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# add home bin
if [ -d "$HOME/.local/bin" ]; then
export PATH="$HOME/.local/bin:$PATH"
fi
4 years ago
# ---------------------------------------------------------------------------
# EDITOR
# ---------------------------------------------------------------------------
if hash nvim 2>/dev/null; then
export EDITOR=nvim
elif hash vim 2>/dev/null; then
export EDITOR=vim
elif hash vi 2>/dev/null; then
export EDITOR=vi
else
export EDITOR=nano
fi
4 years ago
export SVN_EDITOR=$EDITOR
export GIT_EDITOR=$EDITOR
export VISUAL=$EDITOR
alias vi=$EDITOR
4 years ago
# ---------------------------------------------------------------------------
# PROMPT
# ---------------------------------------------------------------------------
if hash starship 2>/dev/null; then
eval "$(starship init bash)"
4 years ago
else
# set a minimalist prompt
red='\[\e[0;31m\]' # Red
green='\[\e[0;32m\]' # Green
blue='\[\e[0;34m\]' # Bold Blue
boldred='\[\e[1;31m\]' # Bold Red
reset='\[\e[0m\]' # Text Reset
if [ "$USER" = "root" ] ; then
# $bold$red
PROMPT_USER_COLOR=$boldred
PROMPT_SYMBOL="#"
else
PROMPT_USER_COLOR=$green
PROMPT_SYMBOL="$"
fi
if [[ -n "$SSH_CLIENT$SSH2_CLIENT$SSH_TTY" ]] ; then
PROMPT_SSH="@\h"
else
PROMPT_SSH=""
fi
PS1="$PROMPT_USER_COLOR\u$PROMPT_SSH $blue\w$reset $PROMPT_SYMBOL "
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_ONLY_IN_REPO=1
GIT_PROMPT_IGNORE_SUBMODULES=1
GIT_PROMPT_WITH_VIRTUAL_ENV=0
GIT_PROMPT_THEME=Solarized_Yax
source $HOME/.bash-git-prompt/gitprompt.sh
fi
4 years ago
fi
# ---------------------------------------------------------------------------
# ALIASES
# ---------------------------------------------------------------------------
if hash exa 2>/dev/null; then
alias ll="exa --long --group-directories-first --classify --git"
alias la="ll --all"
else
alias ll="ls -lv --group-directories-first --ignore=.." # show long listing but no hidden dotfiles except "."
alias la='ls -lav'
fi
alias rm='rm --interactive --verbose'
alias mv='mv --interactive --verbose'
alias cp='cp --verbose --interactive'
if hash wget 2>/dev/null; then
alias wget='wget -c'
fi
alias dmesg='dmesg -T'
alias grep='grep --color'
4 years ago
if hash python3 2>/dev/null; then
alias serve="python3 -m $(python3 -c 'import sys; print("http.server" if sys.version_info[:2] > (2,7) else "SimpleHTTPServer")')"
fi
if hash tmux 2>/dev/null; then
alias ta='tmux attach'
alias tkill="for s in \$(tmux list-sessions | awk -F ':' '{print \$1}' | fzf); do tmux kill-session -t \$s; done;"
fi
3 years ago
if hash tig 2>/dev/null; then
alias tiga='tig --all'
fi
3 years ago
if hash fd 2>/dev/null; then
alias fdfind='fd'
fi
if command -v most > /dev/null 2>&1; then
export PAGER="most"
fi
if hash nix-env 2>/dev/null; then
alias nix-update='nix-channel --update && nix-env -u'
fi
# ---------------------------------------------------------------------------
# COMPLETIONS
# ---------------------------------------------------------------------------
complete -W "\`grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' ?akefile | sed 's/[^a-zA-Z0-9_.-]*$//'\`" make
# -------------------------------------------------------------
3 years ago
# Source .bashrc.d files
# -------------------------------------------------------------
if [ -d "$HOME/.bashrc.d/" ]; then
for file in ~/.bashrc.d/*.bashrc; do
. "$file"
done
fi
2 years ago
# ---------------------------------------------------------------------------
# History
# ---------------------------------------------------------------------------
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# store multiline commands
shopt -s cmdhist
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=2000
HISTFILESIZE=2000
2 years ago
2 years ago
# don't story history commands
HISTIGNORE=history*
2 years ago
# merge history b/w sessions
PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
HISTFILE=~/.bash_history
2 years ago
# Hishtory (https://github.com/ddworken/hishtory)
if [ -d "$HOME/.hishtory/" ]; then
export PATH="$PATH:$HOME/.hishtory"
source $HOME/.hishtory/config.sh
fi
# enable history
set -o history