-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_bashrc
271 lines (226 loc) · 9.7 KB
/
dot_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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# Enable the subsequent settings only in interactive sessions
case $- in
*i*) ;;
*) return ;;
esac
# Path to your oh-my-bash installation.
export OSH="$HOME"/.oh-my-bash
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-bash is loaded.
OSH_THEME="kls"
# If you set OSH_THEME to "random", you can ignore themes you don't like.
# OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo")
# Uncomment the following line to use case-sensitive completion.
# OMB_CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# OMB_HYPHEN_SENSITIVE="false"
# Uncomment the following line to disable bi-weekly auto-update checks.
DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_OSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you don't want the repository to be considered dirty
# if there are untracked files.
SCM_GIT_DISABLE_UNTRACKED_DIRTY="true"
# Uncomment the following line if you want to completely ignore the presence
# of untracked files in the repository.
SCM_GIT_IGNORE_UNTRACKED="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output. One of the following values can
# be used to specify the timestamp format.
# * 'mm/dd/yyyy' # mm/dd/yyyy + time
# * 'dd.mm.yyyy' # dd.mm.yyyy + time
# * 'yyyy-mm-dd' # yyyy-mm-dd + time
# * '[mm/dd/yyyy]' # [mm/dd/yyyy] + [time] with colors
# * '[dd.mm.yyyy]' # [dd.mm.yyyy] + [time] with colors
# * '[yyyy-mm-dd]' # [yyyy-mm-dd] + [time] with colors
# If not set, the default value is 'yyyy-mm-dd'.
# HIST_STAMPS='yyyy-mm-dd'
# Uncomment the following line if you do not want OMB to overwrite the existing
# aliases by the default OMB aliases defined in lib/*.sh
# OMB_DEFAULT_ALIASES="check"
# Would you like to use another custom folder than $OSH/custom?
# OSH_CUSTOM=/path/to/new-custom-folder
# To disable the uses of "sudo" by oh-my-bash, please set "false" to
# this variable. The default behavior for the empty value is "true".
OMB_USE_SUDO=true
# To enable/disable display of Python virtualenv and condaenv
# OMB_PROMPT_SHOW_PYTHON_VENV=true # enable
# OMB_PROMPT_SHOW_PYTHON_VENV=false # disable
# Disable the trim of the working directory
PROMPT_DIRTRIM=0
# Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*)
# Custom completions may be added to ~/.oh-my-bash/custom/completions/
# Example format: completions=(ssh git bundler gem pip pip3)
# Add wisely, as too many completions slow down shell startup.
completions=(
git
composer
ssh
)
# Which aliases would you like to load? (aliases can be found in ~/.oh-my-bash/aliases/*)
# Custom aliases may be added to ~/.oh-my-bash/custom/aliases/
# Example format: aliases=(vagrant composer git-avh)
# Add wisely, as too many aliases slow down shell startup.
aliases=(
general
)
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-bash/plugins/*)
# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
)
# Which plugins would you like to conditionally load? (plugins can be found in ~/.oh-my-bash/plugins/*)
# Custom plugins may be added to ~/.oh-my-bash/custom/plugins/
# Example format:
# if [ "$DISPLAY" ] || [ "$SSH" ]; then
# plugins+=(tmux-autoattach)
# fi
source "$OSH"/oh-my-bash.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='vim'
fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-bash libs,
# plugins, and themes. Aliases can be placed here, though oh-my-bash
# users are encouraged to define aliases within the OSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias bashconfig="mate ~/.bashrc"
# alias ohmybash="mate ~/.oh-my-bash"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
#PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "$(PWD"'
# User environments
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
export CDPATH=".:$HOME/repos/"
export PATH="$PATH:/opt/freescale-4.5.1-2010.09/bin"
export PATH="$PATH:/opt/gcc-linaro-4.9.4-2017.01/bin"
export PATH="$PATH:/opt/gcc-linaro-7.5.0-2019.12/bin"
export PATH="$PATH:/usr/local/go/bin"
export PATH="$PATH:$HOME/scripts"
# User aliases
alias cp='cp -v'
alias gitex='(GitExtensions.exe . &) > /dev/null 2>&1'
alias gogo='source ~/.bashrc'
alias edit-bashrc='vim ~/.bashrc'
alias gs='git status'
alias files='(explorer.exe . &) > /dev/null 2>&1'
alias get-time='/usr/bin/time -f "\n► Elapsed time: %E | CPU usage: %P | Memory usage: %M KB\n"'
alias make-kernel-arm64='rm images/*.itb; make kernel && make dtb_for_itb && make generate_itb && cp images/*.itb /tftp'
alias rebuild-kernel-arm64='rm images/*.itb; make kernel-rebuild && make dtb_for_itb && make generate_itb && cp images/*.itb /tftp'
alias please='sudo'
alias ag='ag --noheading'
alias cm='chezmoi'
alias glp='command git log --graph -p'
alias glpo='command git log --graph -p --oneline'
alias sysadmin='ssh -i ~/.ssh/id_vms -l sysadmin'
alias git-clean-all='git reset --hard; git clean -fd; git submodule foreach "git reset --hard; git clean -fd"'
alias gsu='command git submodule update --init --recursive'
alias gshow='command git show -p --submodule=diff'
alias ghash='command git --no-pager log -1 --pretty=format:"%C(bold)%h%C(reset) %C(#ff69b4)%H %C(#34e2e2)%s%n"'
# User functions
# Usage: root [IP or partial IP] [-- command]
#
# Connects to a specified IP address via SSH, dynamically constructing the IP
# based on the input format. If '--' is used, the command following it will
# be executed on the target device via SSH.
#
# Parameters:
# IP or partial IP The IP address or partial IP to connect to.
# - Full IP (e.g., "192.168.10.15")
# - Partial IP (e.g., "10.15")
# - Last octet (e.g., "101")
# -- command Optional. Command to be executed on the target device.
# If '--' is specified, the command following it is
# executed on the constructed IP.
#
# Examples:
# root Connects to the default IP "192.168.20.100".
# root 101 Connects to "192.168.20.101".
# root 10.15 Connects to "192.10.15.100".
# root -- reboot Executes "reboot" on the default IP "192.168.20.100".
# root 20.2.3 -- ls Executes "ls" on "192.20.2.3".
function root() {
# Default IP address
default_ip="192.168.20.100"
# If no arguments are provided, connect to the default IP
if [ $# -eq 0 ]; then
echo "Connecting via SSH: root@${default_ip}"
ssh root@${default_ip}
echo
return
fi
# If the first argument is '--', execute the following command on the default IP
if [ "$1" == "--" ]; then
shift
command="$*"
echo "Executing command via SSH: root@${default_ip} '$command'"
ssh root@${default_ip} "$command"
echo
return
fi
# Count the number of dots in the first argument to determine how many octets to modify
dot_count=$(echo "$1" | grep -o '\.' | wc -l)
# Construct the IP address based on the number of dots in the first argument
case $dot_count in
0)
# If there are no dots, use the argument as the last octet
target_ip="${default_ip%.*}.$1" ;;
1)
# If there is one dot, replace the third octet with the first argument
target_ip="${default_ip%.*.*}.$1" ;;
2)
# If there are two dots, replace the second and third octets with the first and second arguments
target_ip="${default_ip%.*}.$1.$2" ;;
esac
# Check if '--' is used in the arguments, indicating a command to be executed on the target IP
if [[ " $* " == *" -- "* ]]; then
# Extract the command part after '--' and execute it on the target IP
command=$(echo "$*" | sed 's/.*-- //')
echo "Executing command via SSH: root@${target_ip} '$command'"
ssh root@${target_ip} "$command"
echo
else
# If no '--' is present, just connect to the target IP
echo "Connecting via SSH: root@${target_ip}"
ssh root@${target_ip}
echo
fi
}
compare-branches() {
if [ "$#" -ne 2 ]; then
echo "Usage: compare-branches <branch1> <branch2>"
return 1
fi
local branch1=$1
local branch2=$2
echo "Comparing branch '$branch1' to '$branch2'..."
echo
diff --color=always <(git ls-tree -r "$branch1" | grep ^160000) \
<(git ls-tree -r "$branch2" | grep ^160000) | diff-so-fancy
}