-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
.bashrc
executable file
·123 lines (102 loc) · 4.27 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
alias config='/usr/bin/git --git-dir=/home/sam/.dotfiles/ --work-tree=/home/sam'
# Enable the subsequent settings only in interactive sessions
case $- in
*i*) ;;
*) return;;
esac
#####---------- EXPORTS ----------###
export BROWSER="firefox"
export EDITOR="nvim"
export VISUAL="nvim"
export LESSHISTFILE=-
export HISTFILE="$HOME/.bash_history"
export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""'
export CDPATH=".:$HOME:$HOME/.config/:$HOME/.local/:$HOME/.local/share/:$HOME/.local/programs"
export LIBVIRT_DEFAULT_URI='qemu:///system'
export CSCOPE_EDITOR="nvim"
eval $(dircolors ~/.dir_colors)
alias vim=nvim
alias ls='ls --color=auto'
alias ll='ls -alh --color=auto'
alias grep='grep --color=auto'
alias neofetch='fastfetch'
alias fetch='fastfetch'
alias lss='du -ah --max-depth 1'
###------------------- PROMPT -----------------------###
function parse_git_dirty {
STATUS="$(git status 2> /dev/null)"
if [[ $? -ne 0 ]]; then printf ""; return; else printf " ["; fi
if echo "${STATUS}" | grep -c "renamed:" &> /dev/null; then printf " >"; else printf ""; fi
if echo "${STATUS}" | grep -c "branch is ahead:" &> /dev/null; then printf " !"; else printf ""; fi
if echo "${STATUS}" | grep -c "new file::" &> /dev/null; then printf " +"; else printf ""; fi
if echo "${STATUS}" | grep -c "Untracked files:" &> /dev/null; then printf " ?"; else printf ""; fi
if echo "${STATUS}" | grep -c "modified:" &> /dev/null; then printf " *"; else printf ""; fi
if echo "${STATUS}" | grep -c "deleted:" &> /dev/null; then printf " -"; else printf ""; fi
printf " ]"
}
parse_git_branch() {
# Long form
git rev-parse --abbrev-ref HEAD 2> /dev/null
# Short form
# git rev-parse --abbrev-ref HEAD 2> /dev/null | sed -e 's/.*\/\(.*\)/\1/'
}
prompt_comment() {
DIR="$HOME/.local/share/promptcomments/"
MESSAGE="$(find "$DIR"/*.txt | shuf -n1)"
cat "$MESSAGE"
}
#PS1="\e[00;36m\]┌─[ \e[00;37m\]\T \d \e[00;36m\]]──\e[00;31m\]>\e[00;37m\] \u\e[00;31m\]@\e[00;37m\]\h\n\e[00;36m\]|\n\e[00;36m\]└────\e[00;31m\]> \e[00;37m\]\w \e[00;31m\]\$ \e[01;37m\]"
#PS1="\[\e[01;37m\]{ \[\e[01;34m\]\w \[\e[01;37m\]} \[\e[01;35m\]\[\$ \]\[\e[01;37m\]"
#PS1="\[\e[1;36m\]\$(parse_git_branch)\[\033[31m\]\$(parse_git_dirty)\[\033[00m\]\n\w\[\e[1;31m\] \[\e[1;36m\]\[\e[1;37m\] "
#PS1="\[\e[1;33m\]\$(parse_git_branch)\[\033[34m\]\$(parse_git_dirty)\n\[\033[1;36m\] \[\e[1;37m\] \w \[\e[1;37m\]\[\e[0;37m\] "
PS1="\[\e[1;33m\]\$(parse_git_branch)\[\033[34m\]\$(parse_git_dirty)\n\[\033[1;34m\] \[\e[1;37m\] \w \[\e[1;36m\]\[\e[0;37m\] "
###---------- ARCHIVE EXTRACT ----------###
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7za e x $1 ;;
*.deb) ar x $1 ;;
*.tar.xz) tar xf $1 ;;
*.tar.zst) unzstd $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
### ---------- OTHER ----------###
HISTSIZE=10000
#SAVEHIST=10000
export LESS_TERMCAP_mb=$'\e[1;36m'
export LESS_TERMCAP_md=$'\e[1;36m'
export LESS_TERMCAP_me=$'\e[1;37m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;34m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;34m'
### ---- npm packages ----- ###
NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$PATH:$NPM_PACKAGES/bin"
# Preserve MANPATH if you already defined it somewhere in your config.
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"
###-------- gnupg -------###
export GPG_TTY=$(tty)
# google-cloud-cli gcloud
# source /etc/profile.d/google-cloud-cli.sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# flutter
export PATH="/usr/bin/flutter/bin:$PATH"