diff options
-rw-r--r-- | bash/.bashrc | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/bash/.bashrc b/bash/.bashrc new file mode 100644 index 0000000..4f6c961 --- /dev/null +++ b/bash/.bashrc | |||
@@ -0,0 +1,104 @@ | |||
1 | # .bashrc | ||
2 | # If not running interactively, don't do anything | ||
3 | [[ $- != *i* ]] && return | ||
4 | |||
5 | # exports | ||
6 | export VISUAL=nvim | ||
7 | export EDITOR="$VISUAL" | ||
8 | export BROWSER=firefox-bin | ||
9 | export PATH=$PATH:$HOME/.local/bin:$HOME/bin | ||
10 | export XDG_CURRENT_DESKTOP=spectrwm | ||
11 | |||
12 | # history | ||
13 | shopt -s histappend | ||
14 | export HISTCONTROL=ignoreboth:erasedups | ||
15 | HISTSIZE=1000 | ||
16 | HISTFILESIZE=2000 | ||
17 | |||
18 | shopt -s expand_aliases dotglob gnu_errfmt histreedit nocasematch autocd globstar checkwinsize cdspell dirspell | ||
19 | |||
20 | bind 'set completion-ignore-case on' | ||
21 | bind 'set show-all-if-ambiguous on' | ||
22 | bind 'set colored-stats on' | ||
23 | |||
24 | # aliases | ||
25 | alias ls='ls --color=auto' | ||
26 | alias ll='ls --color=auto -al' | ||
27 | alias grep='grep --color=auto' | ||
28 | alias fgrep='fgrep --color=auto' | ||
29 | alias egrep='egrep --color=auto' | ||
30 | alias key="vim $HOME/.config/spectrwm/keybindings.conf" | ||
31 | alias wm="vim ~/.config/spectrwm/spectrwm.conf" | ||
32 | alias f="ranger" | ||
33 | alias weather="curl wttr.in" | ||
34 | alias py="/usr/bin/python" | ||
35 | alias pg="ping google.com" | ||
36 | alias pubip="curl ipinfo.io/ip" | ||
37 | alias m="cmus" | ||
38 | alias vimrc="vim $HOME/.config/nvim/init.vim" | ||
39 | alias v="nvim" | ||
40 | alias vim="nvim" | ||
41 | alias sudo="doas " | ||
42 | |||
43 | up() { | ||
44 | curl -F "file=@$*" https://0x0.st | xclip -selection clipboard | ||
45 | } | ||
46 | |||
47 | dict() { | ||
48 | curl dict://dict.org/d:$* | less | ||
49 | } | ||
50 | |||
51 | # prompt | ||
52 | red="\e[31m" | ||
53 | green="\e[32m" | ||
54 | yellow="\e[33m" | ||
55 | cyan="\e[36m" | ||
56 | blue="\e[34m" | ||
57 | magenta="\e[35m" | ||
58 | white="\e[37m" | ||
59 | gray="\e[38;5;241m" | ||
60 | gray1="\e[38;5;239m" | ||
61 | gray2="\e[38;5;237m" | ||
62 | reset="\e[0m" | ||
63 | |||
64 | # stolen from https://github.com/icyphox/dotfiles/blob/master/bash/.bashrc.d/99-prompt.bash | ||
65 | git_branch() { | ||
66 | [[ -d "$PWD/.git" ]] && { | ||
67 | local git_status="$(git status 2> /dev/null)" | ||
68 | local on_branch="On branch ([^${IFS}]*)" | ||
69 | local on_commit="HEAD detached at ([^${IFS}]*)" | ||
70 | status="$(git status --porcelain 2> /dev/null)" | ||
71 | local exit="$?" | ||
72 | color="" | ||
73 | if [[ "$exit" -eq 0 ]]; then | ||
74 | if [[ "${#status}" -eq 0 ]]; then | ||
75 | color="${green}" | ||
76 | else | ||
77 | color="${red}" | ||
78 | fi | ||
79 | else | ||
80 | printf '' | ||
81 | fi | ||
82 | if [[ $git_status =~ $on_branch ]]; then | ||
83 | local branch=${BASH_REMATCH[1]} | ||
84 | printf '%b' "$color$branch$reset" | ||
85 | elif [[ $git_status =~ $on_commit ]]; then | ||
86 | local commit=${BASH_REMATCH[1]} | ||
87 | printf '%b' "$color$commit$reset" | ||
88 | fi | ||
89 | } | ||
90 | } | ||
91 | |||
92 | function prompt_right() { | ||
93 | echo -e "$(git_branch)" | ||
94 | } | ||
95 | |||
96 | function prompt_left() { | ||
97 | echo -e "${gray}\h${reset} ${white}(${reset}${red}\w${reset}${white})${reset}" | ||
98 | } | ||
99 | |||
100 | function prompt() { | ||
101 | compensate=9 | ||
102 | PS1=$(printf "%*s\r%s\n\$ " "$(($(tput cols)+${compensate}))" "$(prompt_right)" "$(prompt_left)") | ||
103 | } | ||
104 | PROMPT_COMMAND=prompt | ||