-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
188 lines (159 loc) · 5.06 KB
/
bashrc
File metadata and controls
188 lines (159 loc) · 5.06 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
## safety and env
set completion-ignore-case on
export BASH_SILENCE_DEPRECATION_WARNING=1
export PATH=$PATH:/usr/local/Cellar/openvpn/2.5.1/sbin
test -f ~/.git-completion.bash && . $_
test -f ~/.console/console.rc && . $_
export EDITOR=vim
export VISUAL=vim
export NVM_DIR="$HOME/.nvm"
export PROMPT_GIT_STATUS_COLOR=$(tput setaf 130)
export PROMPT_PREPOSITION_COLOR=$(tput setaf 39)
if [ -f /etc/this-is-smp-production ]; then
export PS1="\[\e[41m\]\u (SMP PROD)\[\e[0m\] in\$(parse_git_branch)\[\033[00m\] \w $ "
elif [ -f /etc/this-is-smp-staging ]; then
export PS1="\[\e[43m\]\u (SMP STAGING)\[\e[0m\] in\$(parse_git_branch)\[\033[00m\] \w $ "
elif [ -f /etc/this-is-guardeloo-production ]; then
export PS1="\[\e[41m\]\u (GEL PROD)\[\e[0m\] in\$(parse_git_branch)\[\033[00m\] \w $ "
elif [ -f /etc/this-is-guardeloo-staging ]; then
export PS1="\[\e[43m\]\u (GEL STAGING)\[\e[0m\] in\$(parse_git_branch)\[\033[00m\] \w $ "
elif [ -f /etc/this-is-gnst-staging ]; then
export PS1="\[\e[43m\]\u (GNST STAGING)\[\e[0m\] in\$(parse_git_branch)\[\033[00m\] \w $ "
elif [ -f /etc/this-is-gnst-production ]; then
export PS1="\[\e[43m\]\u (GNST PROD)\[\e[0m\] in\$(parse_git_branch)\[\033[00m\] \w $ "
else
. ~/sexy-bash-prompt/.bash_prompt
fi
git config --global core.editor "vi"
export DOCKER_HOST=unix:///var/run/docker.sock
# install it, if it's available.
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
[ -f ~/bin/docker_complete.sh ] && source ~/bin/docker_complete.sh
# function to open the search pane, using batcat (cat on steroids)
fzf_open_with_preview() {
local file
file=$(fzf --tmux --preview 'batcat --style=numbers --color=always --line-range=:300 {}' ) && code "$file"
}
# bind it to CTRL+F (only in interactive shells)
[[ $- == *i* ]] && bind -x '"\C-f": fzgrep'
fzgrep() {
local selected file line
selected=$(rg --no-heading --line-number "${*:-.}" \
| fzf --ansi \
--tmux \
--delimiter : \
--preview 'batcat --style=numbers --color=always --highlight-line {2} {1}' \
--preview-window=up:60%)
[ -z "$selected" ] && return 1
file=$(cut -d: -f1 <<< "$selected")
line=$(cut -d: -f2 <<< "$selected")
code -g "$file:$line"
}
#
#
#
#functions get defined here so they're declared earlier than the aliases
dc() {
if [[ -n "$SSH_CONNECTION" ]]; then
echo "⚠️ Refusing to run docker compose with dev config in remote SSH session (SSH_CONNECTION detected)"
return 1
fi
CMD="docker compose -f ~/main/docker-compose.full-dev.yml"
echo "running $CMD $@"
eval $CMD "$@"
}
caps_to_escape() {
setxkbmap -option caps:escape
}
clip() {
local cmd_output
cmd_output="$("$@" 2>&1)" || return 1
{
echo "$*"
echo "--------------------"
echo "$cmd_output"
} | tee >(wl-copy >/dev/null)
}
setup_vim() {
cd ~/bash-settings
git submodule update --init --recursive
}
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
git_big_files() {
git rev-list --objects --all |
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
sed -n 's/^blob //p' |
sort --numeric-sort --key=2 |
cut -c 1-12,41- |
$(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
}
cdn() {
cd $(printf "%0.s../" $(seq 1 $1 ));
}
mkcd() {
mkdir -p -- "$1" &&
cd -P -- "$1"
}
add_agent() {
eval `ssh-agent`
ssh-add
}
remove_spaces() {
for oldname in *
do
newname=`echo $oldname | sed -e 's/ /_/g'`
if [ "$newname" = "$oldname" ]
then
continue
fi
if [ -e "$newname" ]
then
echo Skipping "$oldname", because "$newname" exists
else
mv "$oldname" "$newname"
fi
done
}
laravel-clear-cache() {
if [ -f artisan ]; then
echo "Clearing Laravel caches..."
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
php artisan optimize:clear
echo "Rebuilding optimized files..."
php artisan config:cache
php artisan route:cache
echo "Done!"
else
echo "artisan file not found. Please navigate to your Laravel project root."
fi
}
docker_mem() {
~/bin/docker_mem.sh
}
gdrive_mount() {
rclone mount "WeeDomGDrive": ~/gdrive --vfs-cache-mode writes &
}
gdrive_umount() {
fusermount -u ~/gdrive
}
# Update vim plugin submodules
update-vim-plugins() {
echo "📦 Updating Vim plugins..."
cd ~/bash-settings || return
git pull --recurse-submodules
git submodule foreach 'branch=$(git rev-parse --abbrev-ref HEAD); git checkout $branch && git pull'
echo "✅ Vim plugins updated."
}
## aliases go here
alias http_here="python3 -m http.server 10234"
alias venv="source venv/bin/activate"
alias psqlx='docker compose exec db psql -U scaffadmin -d scaffsmart -x'
export PATH="/home/weedom/.local/bin:$PATH"
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