-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
145 lines (120 loc) · 3.49 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
# vim: foldmethod=marker
# Commands that should be applied only for interactive shells.
[[ $- == *i* ]] || return
# History {{{
HISTFILESIZE=100000
HISTSIZE=10000
shopt -s histappend
shopt -s checkwinsize
shopt -s extglob
shopt -s globstar
shopt -s checkjobs
# }}}
# Aliases {{{
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
alias lzconf='/usr/bin/lazygit --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
alias k='khal calendar'
alias ki='khal interactive'
alias kl='khal list'
alias ls='ls --color'
alias la='ls --color -al'
alias lg='ledger --strict -f ~/Documents/Ledgers/2023/main.ledger'
alias lgit='lazygit'
alias ll='ls --color -l'
alias nixos-rebuild='sudo nixos-rebuild switch'
alias nm='neomutt'
alias nv='nvim'
alias r='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'
alias t='task'
alias ti='timew'
alias tib='timew billable'
alias tm='task mod'
alias tu='taskwarrior-tui'
alias vi='vim'
alias vs='vim -S'
alias zke='zk edit --interactive'
alias zkl='zk list --interactive'
# }}}
# Scripts & Apps {{{
# May not need this
# if [[ ! -v BASH_COMPLETION_VERSINFO ]]; then
# . "/etc/profile.d/bash_completion.sh"
# fi
if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then
. /usr/share/fzf/completion.bash
. /usr/share/fzf/key-bindings.bash
fi
eval "$(/bin/zoxide init bash )"
GPG_TTY="$(tty)"
export GPG_TTY
/bin/gpg-connect-agent updatestartuptty /bye > /dev/null
# }}}
# Prompt {{{
prompt_git() {
local s='';
local branchName='';
# Check if the current directory is in a Git repository.
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then
# check if the current directory is in .git before running git checks
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then
# Ensure the index is up to date.
git update-index --really-refresh -q &>/dev/null;
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;
fi;
# Get the short symbolic ref.
# If HEAD isn’t a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";
[ -n "${s}" ] && s=" [${s}]";
echo -e "${1}${branchName}${2}${s} ";
else
return;
fi;
}
black="\[\e[30m\]"
red="\[\e[31m\]"
green="\[\e[32m\]"
yellow="\[\e[33m\]"
blue="\[\e[34m\]"
purple="\[\e[35m\]"
cyan="\[\e[36m\]"
gray="\[\e[37m\]"
reset="\[\e[0m\]"
# Trim my path so it doesn't get too long.
export PROMPT_DIRTRIM="3"
# Highlight the user name when logged in as root.
isRoot="";
if [[ "$USER" == "root" ]]; then
isRoot+="\[\e[1;31m\][root]$reset ";
fi;
# Adjust the prompt depending on whether we're in nix shell.
isEnv=""
if [ -n "$IN_NIX_SHELL" ]; then
isEnv+="$yellow[env]$reset "
fi
if [[ "$TERM" == "dumb" ]]; then
PS1="$isRoot$isEnv$reset\w > "
else
PS1="$isRoot$isEnv$gray\w$reset "
PS1+="\[\e[1;32m\]\$(prompt_git)$reset";
PS1+="\[\e[1;33m\]λ$reset "
fi;
export PS1;
# }}}