summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShubham Saini <shubham6405@pm.me>2020-06-24 10:57:07 +0000
committerShubham Saini <shubham6405@pm.me>2020-06-24 10:57:07 +0000
commitebc96979636271f55433607136aaeded622a4d78 (patch)
treeb9af8be8108cf09c1ee0f71f0c805e151a6d70bc
parentf5ce37e36e7ce4f3c3c3d837e9a8f33b4dc32190 (diff)
added bash config
-rw-r--r--bash/.bashrc104
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
6export VISUAL=nvim
7export EDITOR="$VISUAL"
8export BROWSER=firefox-bin
9export PATH=$PATH:$HOME/.local/bin:$HOME/bin
10export XDG_CURRENT_DESKTOP=spectrwm
11
12# history
13shopt -s histappend
14export HISTCONTROL=ignoreboth:erasedups
15HISTSIZE=1000
16HISTFILESIZE=2000
17
18shopt -s expand_aliases dotglob gnu_errfmt histreedit nocasematch autocd globstar checkwinsize cdspell dirspell
19
20bind 'set completion-ignore-case on'
21bind 'set show-all-if-ambiguous on'
22bind 'set colored-stats on'
23
24# aliases
25alias ls='ls --color=auto'
26alias ll='ls --color=auto -al'
27alias grep='grep --color=auto'
28alias fgrep='fgrep --color=auto'
29alias egrep='egrep --color=auto'
30alias key="vim $HOME/.config/spectrwm/keybindings.conf"
31alias wm="vim ~/.config/spectrwm/spectrwm.conf"
32alias f="ranger"
33alias weather="curl wttr.in"
34alias py="/usr/bin/python"
35alias pg="ping google.com"
36alias pubip="curl ipinfo.io/ip"
37alias m="cmus"
38alias vimrc="vim $HOME/.config/nvim/init.vim"
39alias v="nvim"
40alias vim="nvim"
41alias sudo="doas "
42
43up() {
44 curl -F "file=@$*" https://0x0.st | xclip -selection clipboard
45}
46
47dict() {
48 curl dict://dict.org/d:$* | less
49}
50
51# prompt
52red="\e[31m"
53green="\e[32m"
54yellow="\e[33m"
55cyan="\e[36m"
56blue="\e[34m"
57magenta="\e[35m"
58white="\e[37m"
59gray="\e[38;5;241m"
60gray1="\e[38;5;239m"
61gray2="\e[38;5;237m"
62reset="\e[0m"
63
64# stolen from https://github.com/icyphox/dotfiles/blob/master/bash/.bashrc.d/99-prompt.bash
65git_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
92function prompt_right() {
93 echo -e "$(git_branch)"
94}
95
96function prompt_left() {
97 echo -e "${gray}\h${reset} ${white}(${reset}${red}\w${reset}${white})${reset}"
98}
99
100function prompt() {
101 compensate=9
102 PS1=$(printf "%*s\r%s\n\$ " "$(($(tput cols)+${compensate}))" "$(prompt_right)" "$(prompt_left)")
103}
104PROMPT_COMMAND=prompt