-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
174 lines (128 loc) · 3.2 KB
/
.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
# Only apply to interactive shell
[[ $- != *i* ]] && return
# Custom profile
# ~/.config/custom/profile should not be committed to the dotfiles repo
# But it allows for work only config, etc.
[[ -f ~/.config/custom/profile ]] && . ~/.config/custom/profile
# Dotfiles
alias config="/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"
config config --local status.showUntrackedFiles no
# XDG base dirs
if command -v xdg-base-dirs >/dev/null 2>&1; then
source xdg-base-dirs
fi
#
# Shell options
#
shopt -s autocd
export HISTCONTROL=ignoredups
shopt -s histappend
# Unlimited bash history
export HISTFILESIZE=
export HISTSIZE=
# Flush to bash history immediately
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# Line wrap on window resize
shopt -s checkwinsize
# Do not allow > to override file, require >|
set -o noclobber
# Disable ^S/^Q nonsense
stty -ixon
#
# Functions
#
# Highlight
if command -v highlight &> /dev/null ; then
alias hl="highlight --stdout -O ansi"
fi
#
# ANSI / terminfo escape sequences
#
BLACK="\[$(tput setaf 0)\]"
RED="\[$(tput setaf 1)\]"
GREEN="\[$(tput setaf 2)\]"
YELLOW="\[$(tput setaf 3)\]"
BLUE="\[$(tput setaf 4)\]"
PURPLE="\[$(tput setaf 5)\]"
CYAN="\[$(tput setaf 6)\]"
WHITE="\[$(tput setaf 7)\]"
BLACK_BG="\[$(tput setab 0)\]"
RED_BG="\[$(tput setab 1)\]"
GREEN_BG="\[$(tput setab 2)\]"
YELLOW_BG="\[$(tput setab 3)\]"
BLUE_BG="\[$(tput setab 4)\]"
PURPLE_BG="\[$(tput setab 5)\]"
CYAN_BG="\[$(tput setab 6)\]"
WHITE_BG="\[$(tput setab 7)\]"
BLINK="\[$(tput blink)\]"
BOLD="\[$(tput bold)\]"
DIM="\[$(tput dim)\]"
REVERSE="\[$(tput rev)\]"
ITALIC_ON="\[$(tput sitm)\]"
ITALIC_OFF="\[$(tput ritm)\]"
HIGHLIGHT_ON="\[$(tput smso)\]"
HIGHLIGHT_OFF="\[$(tput rmso)\]"
UNDERLINE_ON="\[$(tput smul)\]"
UNDERLINE_OFF="\[$(tput rmul)\]"
RESET="\[$(tput sgr0)\]"
#
# Colour program output
#
alias diff="diff --color=auto"
alias grep="grep --color=auto"
alias ip="ip --color=auto"
export LESS="-R --use-color"
export MANPAGER="less -R --use-color -Dd+r -Du+b"
man() {
# md - program name and heading names
# me - seemingly random (often includes options in usage section)
# so - status line
# se - seemingly random
# us - options, arguments, file system paths
# ue - seemingly random
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;35m' \
LESS_TERMCAP_ue=$'\e[0m' \
command man "$@"
}
#
# Aliases
#
if command -v lsd &> /dev/null ; then
alias ls="lsd --group-dirs=first"
alias lsize="ls -Alh --total-size"
alias ltree="ls --tree"
else
alias ls="ls -Xh --group-directories-first --color=auto"
alias lsize="ls -Alh --size"
fi
alias la="ls -Ah"
alias ll="ls -lh"
alias lla="ls -Alh"
alias egrep="grep -E"
alias fgrep="grep -F"
# Safety
alias mv="mv -i"
alias rm="rm -I"
alias cp="cp -i"
# Emacs
if command -v emacs &> /dev/null ; then
alias emacs="emacsclient -c -a 'emacs'"
fi
#
# Bash prompt
# See: ANSI / terminfo above
# See: https://man.archlinux.org/man/bash.1#PROMPTING
#
export PS1="${BOLD}${CYAN}\w ${GREEN}\$${RESET} "
export PS2="${BOLD}${BLUE}>${RESET} "
export PS3=""
export PS4="${BOLD}${BLUE}+${RESET} "
#
# Fun
#
alias starwars="telnet towel.blinkenlights.nl"