-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
196 lines (162 loc) · 4.64 KB
/
bashrc
File metadata and controls
196 lines (162 loc) · 4.64 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
if [ "$TMUX" == "" ] && [ "$TERM_PROGRAM" != "vscode" ]; then
tmux
fi
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
alias ls='ls -G'
alias ll='ls -l'
alias vi='nvim -u ~/.vimrc'
alias vim='nvim -u ~/.vimrc'
alias cdf='cd `dirname $(fzf)`'
alias cdw="cd /Users/$USER/work/\`find ~/work/ -maxdepth 3 | sed \"s/\\/Users\\/$USER\\/work\\///g\" | fzf\`"
alias cdd="cd \`find . -maxdepth 3 | sed \"s/\\/Users\\/$USER\\/work\\///g\" | fzf\`"
function f() {
find . -name "*${1}*"
}
name_window()
{
export TPREFIX="$1"
export CMT_PREFIX="$1"
tmux rename-window "$TPREFIX"
}
gwt()
{
if [[ "$TPREFIX" == "" ]]; then
echo "TPREFIX is empty"
return
fi
WT_DIR="$HOME/work/wt/$TPREFIX"
if [[ ! -d "$WT_DIR" ]]; then
echo "worktree dir $WT_DIR doesn't exist or is not a directory"
return
fi
cd $WT_DIR
}
# Get and set the current window name if we are in a named window already
if [[ -n "$TMUX" ]]; then
NAME="$(tmux display-message -p '#W')"
if [[ "$NAME" != "bash" ]]; then
name_window "$NAME"
fi
fi
git_color()
{
local git_status="$(git status 2> /dev/null)"
if [[ $git_status =~ "Changes to be committed" ]]; then
echo -e "\001\033[0;32m\002" # green
elif [[ $git_status =~ "have diverged" ]]; then
echo -e "\001\033[0;37m\002" # gray
elif [[ $git_status =~ "Your branch is ahead of" ]]; then
echo -e "\001\033[0;37m\002" # gray
elif [[ ! $git_status =~ "working tree clean" ]]; then
echo -e "\001\033[0;31m\002" # red
elif [[ $git_status =~ "nothing to commit" ]]; then
echo -e "\001\033[0;34m\002" # blue
else
echo -e "\001\033[0;33m\002" # yellow
fi
}
git_prompt() {
echo "\$(git_color)"'$(__git_ps1)'
}
get_prefix() {
echo "\001\033[0;35m\002 "'[$TPREFIX]'
}
set_prompt() {
PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w \[\e[34m\]'
PS1+="$(git_prompt)"
PS1+="$(get_prefix)"
PS1+='\n\[\e[0m\]'
PS1+='o/ '
export PS1
}
ps1_simple_version() {
PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w \[\e[34m\]'
PS1+='\n\[\e[0m\]o/ '
export PS1
}
function virg() {
files="`rg "$1" -l`"
vi -p $files
}
#export TERM=xterm-256color
export EDITOR=/usr/local/bin/vim
export PATH=~/environment/bin:/opt/local/bin:~/bin:$PATH
source ~/environment/scripts/git-completion.bash
source ~/environment/scripts/git-prompt.sh
if [ -f ~/environment/extra/bashrc ]; then
source ~/environment/extra/bashrc
fi
alias notecheck=checknotes
function format_check()
{
checknotes
# echo "Do you want to run formatter? (y/N)"
# read VALUE
# case $VALUE in
# "Y" )
# formatter
# ;;
# "y" )
# formatter
# ;;
# esac
# echo
# echo "--------------------------"
git s; pause
gitall
}
function push_check()
{
BRANCH_NAME="$(git branch -vv | grep '^\*')"
echo "${BRANCH_NAME}"
echo "Push? (y/N)"
read VALUE
case $VALUE in
"Y" )
git push
;;
"y" )
git push
;;
esac
}
# alias gmain='if grep -q "main" <<< "`git branch -r`" ; then echo "origin/main"; else echo "origin/master"; fi'
alias gc='format_check && git commit'
alias gcrev='gc -m"Code review" && push_check'
alias gcam='gtt -5 && gc --amend'
alias gcwip='git commit -m"WIP: $(git branch --show-current)"'
alias gcm='git commit -m'
alias gcfix='gc -m"Fix" && push_check'
alias gt='git t'
alias gtt='git t'
alias gs='git s'
alias grm='git fetch --all && git rebase --interactive `gmain`'
alias grd='git fetch --all && git rebase --interactive origin/develop'
alias gbm='git branch -a | grep marcos'
alias gocheck='goimports -w .; golint .'
alias greset='gcwip -a; git fetch --all && git reset --hard `gmain`'
function gtm()
{
BRANCHES="$(git branch | awk '{ print $NF }')"
gtt ${BRANCHES}
}
set_prompt
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
export FZF_DEFAULT_COMMAND='rg --files .'
export HISTCONTROL=ignoredups
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# agentic-camerata
export CMT_COMMENT_TAG=MGR