-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_bashrc
152 lines (118 loc) · 4.03 KB
/
dot_bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# ~/.bashrc: executed by bash(1) for non-login shells.
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export XDG_CACHE_HOME="$HOME/.cache"
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
HISTFILE="$HOME/.bash_history"
HISTFILESIZE=20000
HISTSIZE=10000
# List of commands that shouldn't be added to the history
HISTIGNORE="ls:ll:ps:history:exit:clear:pwd"
# Avoid duplicates in history
HISTCONTROL=ignoredups:erasedups:ignorespace
# Re-read history file before showing next prompt
PROMPT_COMMAND="history -a; history -r"
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# Save all lines of a multi-line command in the same history entry
shopt -s cmdhist
# Check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s checkwinsize
# The pattern "**" used in a pathname expansion context will match all files and zero or more
# directories and subdirectories.
shopt -s globstar
# Change into directories by just typing the directory name without 'cd'
shopt -s autocd
# When using history substitution, only show the resulting command instead of executing it immediately
shopt -s histverify
if [ "$UID" != 0 ]; then
# Case insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
fi
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# Set colors for the ls command
if [ -x /usr/bin/dircolors ]; then
if [ -f ~/.config/.dir_colors ]; then
eval "$(dircolors -b ~/.config/.dir_colors)"
else
eval "$(dircolors -b)"
fi
fi
# Import shell aliases
if [ -f ~/.aliases ]; then
source ~/.aliases
fi
# Load bash completions
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
git_branch_dirty() {
[[ -z $(git status --porcelain 2> /dev/null) ]] || echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
# Set up prompt
if [[ "$(uname -o)" != "Msys" ]]; then
export PS1='\[\e[34m\]\w\[\e[0m\]\e[38;5;241m\]$(parse_git_branch)\[\e[0m\]\[\e[35m\]$(git_branch_dirty)\[\e[0m\]\n\[\e[35m\]❯\[\e[0m\] '
else
export PS1='\[\e[34m\]\w\[\e[0m\] `__git_ps1` ❯ '
fi
# Make man pages easier to read
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
export VISUAL=vim
export EDITOR=vim
if [ -d "$HOME/bin" ]; then
export PATH="$HOME/bin:$PATH"
fi
_ssh()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* 2>/dev/null | grep -v '[?*]' | cut -d ' ' -f 2-)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
}
complete -F _ssh ssh
export ANSIBLE_NOCOWS=1
export EDITOR='nvim'
export INPUTRC="$XDG_CONFIG_HOME/inputrc"
export LANG="en_US"
export LC_ALL="en_US.UTF-8"
export MANPAGER="nvim +Man!"
export MAVEN_OPTS='-Xmx4096m -Xms1024m'
export PAGER='less'
export VISUAL='nvim'
export LESS='-R'
# Keep these commands at the end of the file
# FZF
[ -s "${XDG_CONFIG_HOME}/fzf/fzf.bash" ] && source "${XDG_CONFIG_HOME}/fzf/fzf.bash"
# NODE VERSION MANAGER
export NVM_DIR="${XDG_CONFIG_HOME}/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# SDKMAN
[ -d "$HOME/bin/sdkman" ] && export SDKMAN_DIR="$HOME/bin/sdkman"
[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ] && source "$SDKMAN_DIR/bin/sdkman-init.sh"
# vim: set filetype=bash :