author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Wed, 08 Jun 2022 15:38:53 +0300 | |
changeset 999 | fb93b077af25 |
parent 998 | 1b3bc0a2de41 |
child 1002 | a9073ca0921b |
permissions | -rw-r--r-- |
250
405b343c1214
Add remainder how debug.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
242
diff
changeset
|
1 |
|
405b343c1214
Add remainder how debug.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
242
diff
changeset
|
2 |
# set -x |
405b343c1214
Add remainder how debug.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
242
diff
changeset
|
3 |
# set -u |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
4 |
|
977
0b4affe58cff
Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
976
diff
changeset
|
5 |
if [[ -f ~/.env.bash ]]; then |
0b4affe58cff
Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
976
diff
changeset
|
6 |
. ~/.env.bash |
282 | 7 |
fi |
8 |
||
915
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
9 |
shopt -s checkwinsize |
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
10 |
shopt -s promptvars |
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
11 |
|
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
12 |
_my_ruler_handler() { |
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
13 |
local ruler='================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================' |
916
6abe6497819a
Added fallback to "stty" if "tput" is missing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
915
diff
changeset
|
14 |
if [[ -x /usr/bin/tput ]]; then |
6abe6497819a
Added fallback to "stty" if "tput" is missing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
915
diff
changeset
|
15 |
local size=`/usr/bin/tput cols` |
919
cdf599c86ccf
/bin/stty is in Debian&Alpine, /usr/bin/stty is in Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
917
diff
changeset
|
16 |
elif [[ -x /bin/stty ]]; then |
cdf599c86ccf
/bin/stty is in Debian&Alpine, /usr/bin/stty is in Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
917
diff
changeset
|
17 |
local size=`/bin/stty size | { read x y; echo $y; }` |
cdf599c86ccf
/bin/stty is in Debian&Alpine, /usr/bin/stty is in Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
917
diff
changeset
|
18 |
elif [[ -x /usr/bin/stty ]]; then |
cdf599c86ccf
/bin/stty is in Debian&Alpine, /usr/bin/stty is in Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
917
diff
changeset
|
19 |
local size=`/usr/bin/stty size | { read x y; echo $y; }` |
916
6abe6497819a
Added fallback to "stty" if "tput" is missing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
915
diff
changeset
|
20 |
else |
919
cdf599c86ccf
/bin/stty is in Debian&Alpine, /usr/bin/stty is in Cygwin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
917
diff
changeset
|
21 |
local size=80 |
916
6abe6497819a
Added fallback to "stty" if "tput" is missing.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
915
diff
changeset
|
22 |
fi |
915
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
23 |
ruler=${ruler:0:${size}} |
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
24 |
_my_ruler=$ruler |
892
5bb386e5dbf6
Set length of ruler line to terminal width. Made it more visible.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
888
diff
changeset
|
25 |
} |
987
e0ffdc132f41
TERM is missing when run non-interactively through SSH. Disable ruler in non-interacticve session.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
978
diff
changeset
|
26 |
case $- in |
e0ffdc132f41
TERM is missing when run non-interactively through SSH. Disable ruler in non-interacticve session.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
978
diff
changeset
|
27 |
*i*) |
e0ffdc132f41
TERM is missing when run non-interactively through SSH. Disable ruler in non-interacticve session.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
978
diff
changeset
|
28 |
_my_ruler_handler |
e0ffdc132f41
TERM is missing when run non-interactively through SSH. Disable ruler in non-interacticve session.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
978
diff
changeset
|
29 |
trap '_my_ruler_handler' SIGWINCH |
e0ffdc132f41
TERM is missing when run non-interactively through SSH. Disable ruler in non-interacticve session.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
978
diff
changeset
|
30 |
;; |
e0ffdc132f41
TERM is missing when run non-interactively through SSH. Disable ruler in non-interacticve session.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
978
diff
changeset
|
31 |
esac |
892
5bb386e5dbf6
Set length of ruler line to terminal width. Made it more visible.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
888
diff
changeset
|
32 |
|
915
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
33 |
PS1='\n${_my_ruler}\r$?|\u@\h \w \nbash# ' |
633
ef2436c18276
Print current dir at prompt. Remove broken code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
619
diff
changeset
|
34 |
PS2='> ' |
849
04cb764675f3
Do not try to set title inside Emacs term emulator.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
848
diff
changeset
|
35 |
|
182
af9e9693646e
Set magenta bold font.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
181
diff
changeset
|
36 |
case "$TERM" in |
949
2e7205b69973
Adtivated TERM=mintty for mintty as Gradle now supports it natively (as of v5.2).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
946
diff
changeset
|
37 |
xterm*|eterm-color|screen|linux|mintty*|cygwin) |
915
691db6af02e4
Change rules size only on SIGWINCH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
909
diff
changeset
|
38 |
PS1=$'\n\e[34m\e[1m${_my_ruler}\r$?|\e[31m\u\e[35m@\h\e[0m\e[36m \w \n\[\e[1m\e[31m\]bash#\[\e[0m\] ' |
828
235bf6715fc6
Use $'' syntax to get rid of \033 in flavor of \e.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
811
diff
changeset
|
39 |
PS2=$'\[\e[32m\]> \[\e[0m\]' |
182
af9e9693646e
Set magenta bold font.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
181
diff
changeset
|
40 |
;; |
af9e9693646e
Set magenta bold font.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
181
diff
changeset
|
41 |
esac |
849
04cb764675f3
Do not try to set title inside Emacs term emulator.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
848
diff
changeset
|
42 |
# Set current directory in terminal emulator title. |
04cb764675f3
Do not try to set title inside Emacs term emulator.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
848
diff
changeset
|
43 |
case "$TERM" in |
949
2e7205b69973
Adtivated TERM=mintty for mintty as Gradle now supports it natively (as of v5.2).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
946
diff
changeset
|
44 |
xterm*|screen|linux|mintty*|cygwin) |
901
5e5c705d2831
Added user/host to terminal title.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
900
diff
changeset
|
45 |
PS1=$'\e]0;bash \u@\h \w\a'"$PS1" |
849
04cb764675f3
Do not try to set title inside Emacs term emulator.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
848
diff
changeset
|
46 |
;; |
04cb764675f3
Do not try to set title inside Emacs term emulator.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
848
diff
changeset
|
47 |
esac |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
48 |
|
304
c6ae628708d5
Enable dircolors. Check for 'dircolors' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
300
diff
changeset
|
49 |
if command -v dircolors >/dev/null 2>&1 && [[ -f ~/.dircolors ]]; then |
c6ae628708d5
Enable dircolors. Check for 'dircolors' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
300
diff
changeset
|
50 |
eval "`dircolors -b ~/.dircolors`" |
c6ae628708d5
Enable dircolors. Check for 'dircolors' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
300
diff
changeset
|
51 |
fi |
208
ba6619e43b22
Add '.dircolors' but don't enable it.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
193
diff
changeset
|
52 |
|
482
3860547a5594
Set HISTTIMEFORMAT to force Bash to store timestamp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
481
diff
changeset
|
53 |
# Can be XXX /visible. I like bell. |
3860547a5594
Set HISTTIMEFORMAT to force Bash to store timestamp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
481
diff
changeset
|
54 |
# set bell-style visible |
3860547a5594
Set HISTTIMEFORMAT to force Bash to store timestamp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
481
diff
changeset
|
55 |
|
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
56 |
# Don't store duplicate adjacent items in the history. |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
57 |
# ignorespace do not save lines that start with space |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
58 |
# erasedups all previous lines matching the current line to be removed from |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
59 |
# the history list before that line is saved |
481 | 60 |
HISTCONTROL=ignorespace:erasedups |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
61 |
|
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
62 |
# Don't store noisy/dumb items. |
104
653e4ea98ff9
Exclude 'cd' command from history which comes from MC.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
93
diff
changeset
|
63 |
# TIP: MC command start with space. |
107
43f69ef5ec58
Remove ? from patterns as I previously incorrectly understand its meaning.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
106
diff
changeset
|
64 |
HISTIGNORE=\ |
993
43ccab60bb32
Exclude space prefixed commands from Bash history. This include Midnight Commander UI prompt (not shell).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
991
diff
changeset
|
65 |
" *":\ |
107
43f69ef5ec58
Remove ? from patterns as I previously incorrectly understand its meaning.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
106
diff
changeset
|
66 |
"vlc *":ls:pwd |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
67 |
|
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
68 |
# To these options assigned default value, as they satisfy my needs I comment them. |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
69 |
# HISTFILE=~/.bash_history # where is command history stored |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
70 |
# HISTFILESIZE=500 # how many lines been in $HISTFILE |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
71 |
# HISTSIZE=500 # how many lines been stored in bash process |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
72 |
|
482
3860547a5594
Set HISTTIMEFORMAT to force Bash to store timestamp.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
481
diff
changeset
|
73 |
HISTTIMEFORMAT="%F %T " |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
74 |
|
171
47aa0a6acc75
Make Bash append rather than overwrite the history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
168
diff
changeset
|
75 |
# Make Bash append rather than overwrite the history. |
47aa0a6acc75
Make Bash append rather than overwrite the history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
168
diff
changeset
|
76 |
shopt -s histappend |
47aa0a6acc75
Make Bash append rather than overwrite the history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
168
diff
changeset
|
77 |
|
193
2e4cebaae3cc
histreedit histverify
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
182
diff
changeset
|
78 |
shopt -s histreedit |
2e4cebaae3cc
histreedit histverify
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
182
diff
changeset
|
79 |
shopt -s histverify |
2e4cebaae3cc
histreedit histverify
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
182
diff
changeset
|
80 |
|
483
f02dbcb71260
Technique to share command history across Bash secctions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
482
diff
changeset
|
81 |
# Technique to share command history across Bash secctions. |
f02dbcb71260
Technique to share command history across Bash secctions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
482
diff
changeset
|
82 |
# Just run: |
f02dbcb71260
Technique to share command history across Bash secctions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
482
diff
changeset
|
83 |
# history -n |
f02dbcb71260
Technique to share command history across Bash secctions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
482
diff
changeset
|
84 |
# to reload history. |
f02dbcb71260
Technique to share command history across Bash secctions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
482
diff
changeset
|
85 |
# This setting automatically update history file, but ignore HISTCONTROL=erasedups settings. |
f02dbcb71260
Technique to share command history across Bash secctions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
482
diff
changeset
|
86 |
# PROMPT_COMMAND='history -a' |
f02dbcb71260
Technique to share command history across Bash secctions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
482
diff
changeset
|
87 |
|
28
da6841fb89e9
Minor errors in the spelling of a directory component in a cd command will be corrected.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
16
diff
changeset
|
88 |
# Minor errors in the spelling of a directory component in a cd command will |
da6841fb89e9
Minor errors in the spelling of a directory component in a cd command will be corrected.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
16
diff
changeset
|
89 |
# be corrected. |
da6841fb89e9
Minor errors in the spelling of a directory component in a cd command will be corrected.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
16
diff
changeset
|
90 |
shopt -s cdspell |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
91 |
|
43
6c53a61678d7
Added useful bash settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
42
diff
changeset
|
92 |
# Save all lines of a multiple-line command in the same history entry. |
6c53a61678d7
Added useful bash settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
42
diff
changeset
|
93 |
shopt -s cmdhist |
6c53a61678d7
Added useful bash settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
42
diff
changeset
|
94 |
|
6c53a61678d7
Added useful bash settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
42
diff
changeset
|
95 |
# Allows files beginning with a dot ('.') to be returned in the results of path-name expansion. |
6c53a61678d7
Added useful bash settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
42
diff
changeset
|
96 |
shopt -s dotglob |
6c53a61678d7
Added useful bash settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
42
diff
changeset
|
97 |
|
168
0371cfe5a8f5
ksh-88 egrep-style extended pattern matching .
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
157
diff
changeset
|
98 |
# ksh-88 egrep-style extended pattern matching. |
0371cfe5a8f5
ksh-88 egrep-style extended pattern matching .
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
157
diff
changeset
|
99 |
shopt -s extglob |
0371cfe5a8f5
ksh-88 egrep-style extended pattern matching .
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
157
diff
changeset
|
100 |
|
619
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
101 |
# Enable '**' patttern matching. If the pattern is followed by a /, only dirs match. |
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
102 |
shopt -s globstar |
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
103 |
|
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
104 |
# Ignore case in glob. |
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
105 |
shopt -s nocaseglob |
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
106 |
|
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
107 |
# Show stopped jobs before exit. Next ^D force to leave bash... |
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
108 |
shopt -s checkjobs |
8080fc135a18
Enable '**' patttern matching. If the pattern is followed by a /, only dirs
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
618
diff
changeset
|
109 |
|
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
110 |
# Let me have core dumps |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
111 |
ulimit -c unlimited |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
112 |
|
44
e4703f904e4b
Use bash-completion, if available.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
43
diff
changeset
|
113 |
################################################################ |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
114 |
# shortcut aliases |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
115 |
|
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
116 |
alias ..="cd .." #go to parent dir |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
117 |
alias ...="cd ../.." #go to grandparent dir |
109
40feef132306
Fix "alias: --: неправильная опция".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
107
diff
changeset
|
118 |
alias -- -="cd -" # go to previous dir |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
119 |
alias l.='ls -d .*' #list hidden files |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
120 |
alias ll='ls -lhrt' #extra info compared to "l" |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
121 |
alias lld='ls -lUd */' #list directories |
231
84c9533f2675
I prefer EN man pages.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
230
diff
changeset
|
122 |
# I prefer EN man pages. |
84c9533f2675
I prefer EN man pages.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
230
diff
changeset
|
123 |
alias man='LANG=C man' |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
124 |
|
251
30e947dddaa3
Shorter alias for jobs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
250
diff
changeset
|
125 |
alias j='jobs ' |
30e947dddaa3
Shorter alias for jobs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
250
diff
changeset
|
126 |
|
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
127 |
# make and change to a directory |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
128 |
md () { mkdir -p "$1" && cd "$1"; } |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
129 |
|
704
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
130 |
myfind() { find . -iname "$1"; } |
783
b1ace79cf017
Because I remove utils/pathsearch project I save some usage example from man page.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
777
diff
changeset
|
131 |
|
b1ace79cf017
Because I remove utils/pathsearch project I save some usage example from man page.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
777
diff
changeset
|
132 |
# Usage example: |
b1ace79cf017
Because I remove utils/pathsearch project I save some usage example from man page.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
777
diff
changeset
|
133 |
# mypath EMACSLOADPATH '*.el' \; |
b1ace79cf017
Because I remove utils/pathsearch project I save some usage example from man page.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
777
diff
changeset
|
134 |
# mypath TEXINPUTS "*cyr*" |
b1ace79cf017
Because I remove utils/pathsearch project I save some usage example from man page.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
777
diff
changeset
|
135 |
# VAR=`cygpath -p '$INCLUDE'` mypath VAR "windows*" |
704
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
136 |
mypath() { |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
137 |
local var="$2" |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
138 |
[[ -z $var ]] && var=PATH |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
139 |
local delim="$3" |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
140 |
[[ -z $delim ]] && delim=: |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
141 |
local split |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
142 |
IFS="$delim" command eval "read -ra split <<< \"\${$var}\"" |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
143 |
for dir in "${split[@]}"; do |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
144 |
[[ -z "$dir" ]] && continue |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
145 |
if [[ -f "$dir"/"$1" ]]; then |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
146 |
echo "$dir"/"$1" |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
147 |
else |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
148 |
ls -d "$dir"/$1 2>/dev/null | cat |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
149 |
fi |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
150 |
done |
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
151 |
} |
705
4a77587b0617
Completion for mypath Bash helper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
704
diff
changeset
|
152 |
_mypath() { |
4a77587b0617
Completion for mypath Bash helper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
704
diff
changeset
|
153 |
if [[ $COMP_CWORD = 2 ]]; then |
4a77587b0617
Completion for mypath Bash helper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
704
diff
changeset
|
154 |
COMPREPLY=( $(compgen -v -- "${COMP_WORDS[2]}") ) |
4a77587b0617
Completion for mypath Bash helper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
704
diff
changeset
|
155 |
fi |
4a77587b0617
Completion for mypath Bash helper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
704
diff
changeset
|
156 |
} |
4a77587b0617
Completion for mypath Bash helper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
704
diff
changeset
|
157 |
complete -F _mypath mypath |
704
e1347fd80853
myfind and mypath interactive bash session helper function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
703
diff
changeset
|
158 |
|
305
72032902cdd1
Enable colours for 'ls' and 'grep'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
304
diff
changeset
|
159 |
# LANG=C for speed. |
884
e400725dd13d
It's impossible to disable -n so it's better to remove it.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
860
diff
changeset
|
160 |
alias grep='GREP_COLOR="31;47" LANG=C grep --color=auto' |
799
c85ac0f4c0f5
Fix: ls --color=auto does not work in NetBSD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
795
diff
changeset
|
161 |
case $OSTYPE in |
c85ac0f4c0f5
Fix: ls --color=auto does not work in NetBSD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
795
diff
changeset
|
162 |
linux*|cygwin) alias ls='ls --color=auto' ;; |
c85ac0f4c0f5
Fix: ls --color=auto does not work in NetBSD.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
795
diff
changeset
|
163 |
esac |
306 | 164 |
alias minicom='minicom -c on' |
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
165 |
|
656
ed0f6aece96c
Remove '-3' option from calendar as it conflict with year argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
653
diff
changeset
|
166 |
# Weeks start on Monday. |
ed0f6aece96c
Remove '-3' option from calendar as it conflict with year argument.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
653
diff
changeset
|
167 |
alias ncal='ncal -M' |
306 | 168 |
|
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
169 |
# alias diff='LC_ALL=C TZ=GMT0 diff -Naur' #normalise diffs for distribution |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
170 |
# alias sudo='sudo env PATH=$PATH' #work around sudo built --with-secure-path (ubuntu) |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
171 |
# alias vim='vim -X' #don't try to contact xserver (which can hang on network issues) |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
172 |
# alias gdb='gdb -tui' #enable the text window interface if possible |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
173 |
|
596
f6be61efe78f
Add 'dquilt' alias for Debian package development.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
594
diff
changeset
|
174 |
alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg" |
f6be61efe78f
Add 'dquilt' alias for Debian package development.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
594
diff
changeset
|
175 |
|
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
176 |
# what most people want from od (hexdump) |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
177 |
# alias hd='od -Ax -tx1z -v' |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
178 |
|
899
d5f00e3d31ec
Disable CYGWIN=noglob for docker-machine.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
896
diff
changeset
|
179 |
case $OSTYPE in |
d5f00e3d31ec
Disable CYGWIN=noglob for docker-machine.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
896
diff
changeset
|
180 |
# CYGWIN=noglob causes https://github.com/docker/machine/issues/4516 |
d5f00e3d31ec
Disable CYGWIN=noglob for docker-machine.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
896
diff
changeset
|
181 |
cygwin) alias docker-machine='CYGWIN= docker-machine' ;; |
900 | 182 |
esac |
951
0f401364a9aa
Replace TERM=mintty with "xterm" as remote Debian doesn't have "mintty" definition.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
949
diff
changeset
|
183 |
case $TERM in |
976
38803c50d0ed
Pass TERM as xterm to "vagrant ssh" because Debian doesn't know TERM "mintty".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
971
diff
changeset
|
184 |
mintty*) |
38803c50d0ed
Pass TERM as xterm to "vagrant ssh" because Debian doesn't know TERM "mintty".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
971
diff
changeset
|
185 |
alias ssh='TERM=xterm ssh' |
38803c50d0ed
Pass TERM as xterm to "vagrant ssh" because Debian doesn't know TERM "mintty".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
971
diff
changeset
|
186 |
alias vagrant='TERM=xterm vagrant' |
38803c50d0ed
Pass TERM as xterm to "vagrant ssh" because Debian doesn't know TERM "mintty".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
971
diff
changeset
|
187 |
;; |
951
0f401364a9aa
Replace TERM=mintty with "xterm" as remote Debian doesn't have "mintty" definition.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
949
diff
changeset
|
188 |
esac |
899
d5f00e3d31ec
Disable CYGWIN=noglob for docker-machine.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
896
diff
changeset
|
189 |
|
57
99d0eb7974d6
Remove --comment-delimiters-on-blank-lines option from indent.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
45
diff
changeset
|
190 |
# --blank-lines-after-procedures --break-before-boolean-operator --braces-on-if-line --braces-on-struct-decl-line |
99d0eb7974d6
Remove --comment-delimiters-on-blank-lines option from indent.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
45
diff
changeset
|
191 |
# --comment-indentationn --space-after-cast --line-comments-indentationn --declaration-indentationn --honour-newlines |
99d0eb7974d6
Remove --comment-delimiters-on-blank-lines option from indent.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
45
diff
changeset
|
192 |
# --no-space-after-function-call-names --no-tabs --struct-brace-indentationn --start-left-side-of-comments |
99d0eb7974d6
Remove --comment-delimiters-on-blank-lines option from indent.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
45
diff
changeset
|
193 |
alias indent-bifit="indent -bap -bbo -br -brs -cdw -ce -cli0 -c0 -cs -d0 -di0 -hnl -l120 -lc90 -i4 -npcs -ppi 3 -npsl -nut -sbi4 -sc" |
45
5c94d2613433
Added alias for reindent code for our job rules.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
44
diff
changeset
|
194 |
|
11
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
195 |
# canonicalize path (including resolving symlinks) |
339675ac5fd3
Base version of .bashrc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff
changeset
|
196 |
# alias realpath='readlink -f' |
32
031655c93305
Special case for CYGWIN to properly display russian letters in rxvt.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
30
diff
changeset
|
197 |
|
469 | 198 |
# Fix lang under X. |
477
d0c29482707d
Switch to kbdd program for manage input method.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
469
diff
changeset
|
199 |
alias en="dbus-send --dest=ru.gentoo.KbddService /ru/gentoo/KbddService ru.gentoo.kbdd.set_layout uint32:0" |
d0c29482707d
Switch to kbdd program for manage input method.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
469
diff
changeset
|
200 |
alias ут="dbus-send --dest=ru.gentoo.KbddService /ru/gentoo/KbddService ru.gentoo.kbdd.set_layout uint32:0" |
469 | 201 |
|
150 | 202 |
################################################################ |
174
f862e6d84d02
Move key binding as dabbrev-expand defined only in bash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
171
diff
changeset
|
203 |
# Key binding. |
f862e6d84d02
Move key binding as dabbrev-expand defined only in bash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
171
diff
changeset
|
204 |
|
176 | 205 |
set -o emacs |
206 |
||
174
f862e6d84d02
Move key binding as dabbrev-expand defined only in bash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
171
diff
changeset
|
207 |
################################################################ |
150 | 208 |
# Completion. |
209 |
||
284
3351fda649d5
Switch to Bash built-in 'test' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
283
diff
changeset
|
210 |
if [[ -f /etc/bash_completion ]]; then |
795
6e8756ef4fdd
Enable bash_completion for Cygwin because new bash version support delayed
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
788
diff
changeset
|
211 |
# in Debian |
6e8756ef4fdd
Enable bash_completion for Cygwin because new bash version support delayed
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
788
diff
changeset
|
212 |
. /etc/bash_completion |
6e8756ef4fdd
Enable bash_completion for Cygwin because new bash version support delayed
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
788
diff
changeset
|
213 |
complete -F _quilt_completion dquilt |
6e8756ef4fdd
Enable bash_completion for Cygwin because new bash version support delayed
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
788
diff
changeset
|
214 |
elif [[ -f /usr/share/bash-completion/bash_completion ]]; then |
6e8756ef4fdd
Enable bash_completion for Cygwin because new bash version support delayed
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
788
diff
changeset
|
215 |
# in Cygwin |
6e8756ef4fdd
Enable bash_completion for Cygwin because new bash version support delayed
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
788
diff
changeset
|
216 |
. /usr/share/bash-completion/bash_completion |
284
3351fda649d5
Switch to Bash built-in 'test' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
283
diff
changeset
|
217 |
elif [[ -f ~/usr/etc/bash_completion ]]; then |
3351fda649d5
Switch to Bash built-in 'test' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
283
diff
changeset
|
218 |
. ~/usr/etc/bash_completion |
240
62bea4f80160
Take more priority for 'bash_completion' instead my completion.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
239
diff
changeset
|
219 |
fi |
283
eb383cf7ba80
Move completions to separate file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
282
diff
changeset
|
220 |
# Load local completions. |
284
3351fda649d5
Switch to Bash built-in 'test' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
283
diff
changeset
|
221 |
if [[ -f ~/.bash_completion ]]; then |
283
eb383cf7ba80
Move completions to separate file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
282
diff
changeset
|
222 |
. ~/.bash_completion |
eb383cf7ba80
Move completions to separate file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
282
diff
changeset
|
223 |
fi |
284
3351fda649d5
Switch to Bash built-in 'test' command.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
283
diff
changeset
|
224 |
if [[ -d ~/.bash_completion.d ]]; then |
283
eb383cf7ba80
Move completions to separate file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
282
diff
changeset
|
225 |
for f in ~/.bash_completion.d/* ~/.bash_completion.d/.*; do |
290
e19be6298b09
Fix error: "bash: .: /cygdrive/d/home/.bash_completion.d/..: является директорией"
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
284
diff
changeset
|
226 |
[[ -f "$f" ]] && . "$f" |
283
eb383cf7ba80
Move completions to separate file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
282
diff
changeset
|
227 |
done |
eb383cf7ba80
Move completions to separate file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
282
diff
changeset
|
228 |
fi |
eb383cf7ba80
Move completions to separate file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
282
diff
changeset
|
229 |
|
449
63fe7a1ebae4
Load custom settings (user editable).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
309
diff
changeset
|
230 |
################################################################ |
977
0b4affe58cff
Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
976
diff
changeset
|
231 |
# Load user defined settings. |
449
63fe7a1ebae4
Load custom settings (user editable).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
309
diff
changeset
|
232 |
# Placed to the end to allow override skel settings. |
63fe7a1ebae4
Load custom settings (user editable).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
309
diff
changeset
|
233 |
|
977
0b4affe58cff
Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
976
diff
changeset
|
234 |
if [[ -f ~/.env ]]; then |
978
8f0e780cabcf
Allow ~/.env file to be without "export" prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
977
diff
changeset
|
235 |
set -a |
977
0b4affe58cff
Renamed .env => .bash.env to free .env name for user customization (famous dotenv file).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
976
diff
changeset
|
236 |
. ~/.env |
978
8f0e780cabcf
Allow ~/.env file to be without "export" prefix.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
977
diff
changeset
|
237 |
set +a |
449
63fe7a1ebae4
Load custom settings (user editable).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
309
diff
changeset
|
238 |
fi |
63fe7a1ebae4
Load custom settings (user editable).
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
309
diff
changeset
|
239 |
|
685
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
240 |
################################################################ |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
241 |
# Useful functions. |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
242 |
|
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
243 |
datediff() { |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
244 |
[[ -n "$1" ]] || { echo first argument is missing; return 1; } |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
245 |
[[ -n "$2" ]] || { echo second argument is missing; return 1; } |
834
31202b672717
Switch arguments order.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
828
diff
changeset
|
246 |
local diff=$(( $(date -d "$1" +%s) - $(date -d "$2" +%s) )) |
685
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
247 |
local sec=$(( diff % 60 )) |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
248 |
diff=$(( diff / 60 )) |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
249 |
local min=$(( diff % 60 )) |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
250 |
diff=$(( diff / 60 )) |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
251 |
local hour=$(( diff % 24 )) |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
252 |
local day=$(( diff / 24 )) |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
253 |
echo $day days $hour hours $min minutes $sec seconds |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
254 |
} |
c2b825bf0353
Add datediff useful function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
656
diff
changeset
|
255 |
|
811
b41cb471a3d0
Add function for linguistic analysis.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
799
diff
changeset
|
256 |
# For linguistic analysis. |
b41cb471a3d0
Add function for linguistic analysis.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
799
diff
changeset
|
257 |
myfreq() { |
b41cb471a3d0
Add function for linguistic analysis.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
799
diff
changeset
|
258 |
ag --nofilename -C1 -- "$1" |
b41cb471a3d0
Add function for linguistic analysis.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
799
diff
changeset
|
259 |
printf '\n\n\e[31mtotal:\e[0m ' |
b41cb471a3d0
Add function for linguistic analysis.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
799
diff
changeset
|
260 |
ag --nofilename --count -- "$1" | awk '{c += $1} END {print c}' |
b41cb471a3d0
Add function for linguistic analysis.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
799
diff
changeset
|
261 |
} |
888
ec96d18f51b0
Command to spoof git commit date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
884
diff
changeset
|
262 |
|
ec96d18f51b0
Command to spoof git commit date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
884
diff
changeset
|
263 |
mygit-date() { |
937
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
264 |
if [[ -n "$2" ]]; then |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
265 |
echo Provide only one arg. |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
266 |
return 1; |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
267 |
fi |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
268 |
local sec=$(($RANDOM % 60)) |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
269 |
if [[ ${#sec} = 1 ]]; then |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
270 |
sec=0$sec |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
271 |
fi |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
272 |
if [[ "$1" =~ ^[0-9]{2}:[0-9]{2}$ ]]; then |
909
a2940bea3a6d
Updated mygit-date to accept hour+minute, assume current day + random seconds.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
901
diff
changeset
|
273 |
local yyyymmdd=`date +%F` |
a2940bea3a6d
Updated mygit-date to accept hour+minute, assume current day + random seconds.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
901
diff
changeset
|
274 |
set "$yyyymmdd $1:$sec" |
937
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
275 |
elif [[ "$1" =~ ^[0-9]{2}' '[0-9]{2}:[0-9]{2}$ ]]; then |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
276 |
local yyyymm=`date +%Y-%m` |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
277 |
set "$yyyymm-$1:$sec" |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
278 |
elif [[ "$1" =~ ^[0-9]{2}-[0-9]{2}' '[0-9]{2}:[0-9]{2}$ ]]; then |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
279 |
local yyyy=`date +%Y` |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
280 |
set "$yyyy-$1:$sec" |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
281 |
elif [[ "$1" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}' '[0-9]{2}:[0-9]{2}$ ]]; then |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
282 |
set "$1:$sec" |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
283 |
elif [[ "$1" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}' '[0-9]{2}:[0-9]{2}:[0-9]{2}$ ]]; then |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
284 |
: |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
285 |
else |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
286 |
echo 'Unsupported format, try hh:mm, "dd hh:mm", "MM-dd hh:mm", "yyyy-MM-dd hh:mm", "yyyy-MM-dd hh:mm:ss"' |
a2beae97e3d8
Increased the number of supported formats by mygit-date and added strict validation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
922
diff
changeset
|
287 |
return 1; |
909
a2940bea3a6d
Updated mygit-date to accept hour+minute, assume current day + random seconds.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
901
diff
changeset
|
288 |
fi |
888
ec96d18f51b0
Command to spoof git commit date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
884
diff
changeset
|
289 |
echo GIT_COMMITTER_DATE='"'"$1"'"' git commit --amend --no-edit --date '"'"$1"'"' |
ec96d18f51b0
Command to spoof git commit date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
884
diff
changeset
|
290 |
GIT_COMMITTER_DATE="$1" git commit --amend --no-edit --date "$1" |
ec96d18f51b0
Command to spoof git commit date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
884
diff
changeset
|
291 |
} |
ec96d18f51b0
Command to spoof git commit date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
884
diff
changeset
|
292 |
|
945
d9232a82c55a
A way to find releases/heads with given commit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
937
diff
changeset
|
293 |
# https://stackoverflow.com/questions/63794347/find-every-decoration-after-given-git-commit |
d9232a82c55a
A way to find releases/heads with given commit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
937
diff
changeset
|
294 |
mygit-descendants() { |
d9232a82c55a
A way to find releases/heads with given commit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
937
diff
changeset
|
295 |
git log --graph --decorate --oneline --simplify-by-decoration ^"$1" $( |
d9232a82c55a
A way to find releases/heads with given commit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
937
diff
changeset
|
296 |
git branch --all --contains "$1" --format '%(objectname)'; |
d9232a82c55a
A way to find releases/heads with given commit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
937
diff
changeset
|
297 |
git tag --contains "$1" --format '%(objectname)'; |
d9232a82c55a
A way to find releases/heads with given commit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
937
diff
changeset
|
298 |
); |
d9232a82c55a
A way to find releases/heads with given commit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
937
diff
changeset
|
299 |
} |
946
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
300 |
|
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
301 |
mywsl-docker-enable() { |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
302 |
if [[ -z "$1" ]]; then |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
303 |
set default |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
304 |
fi |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
305 |
while IFS= read -r line; do |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
306 |
if [[ ! "$line" =~ ^export ]]; then |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
307 |
continue |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
308 |
fi |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
309 |
if [[ "$line" =~ DOCKER_CERT_PATH ]]; then |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
310 |
local p="${line#*=}" # Strip leading 'export var='. |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
311 |
p="${p#\"}" # Strip leading ". |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
312 |
p="${p%\"}" # Strip final ". |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
313 |
export DOCKER_CERT_PATH=$(wslpath -u $p) |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
314 |
else |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
315 |
eval "$line" |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
316 |
fi |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
317 |
done < <(docker-machine.exe env --shell bash "$1") |
6ac846c89561
Added utility to activate Windows based docker-machine in WSL.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
945
diff
changeset
|
318 |
} |
971
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
319 |
|
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
320 |
mycurl() { |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
321 |
curl -w "\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
322 |
namelookup: %{time_namelookup}\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
323 |
connect: %{time_connect}\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
324 |
appconnect: %{time_appconnect}\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
325 |
pretransfer: %{time_pretransfer}\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
326 |
redirect: %{time_redirect}\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
327 |
starttransfer: %{time_starttransfer}\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
328 |
-------------------------\n\ |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
329 |
total: %{time_total}\n" "$@" |
c4a808f66996
Utility function to enhance curl with time report.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
951
diff
changeset
|
330 |
} |
997
02ca7e4cc631
Added utility function for halting all VBox VMs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
993
diff
changeset
|
331 |
|
998
1b3bc0a2de41
myvbox-stop-all: added support for spaces in the response from "vboxmanage list runningvms".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
997
diff
changeset
|
332 |
myvbox-stop-all() { |
1b3bc0a2de41
myvbox-stop-all: added support for spaces in the response from "vboxmanage list runningvms".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
997
diff
changeset
|
333 |
VBoxManage list runningvms |& while read line; do |
1b3bc0a2de41
myvbox-stop-all: added support for spaces in the response from "vboxmanage list runningvms".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
997
diff
changeset
|
334 |
# Parse UUID in: "Name with spaces" {UUID} |
1b3bc0a2de41
myvbox-stop-all: added support for spaces in the response from "vboxmanage list runningvms".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
997
diff
changeset
|
335 |
line=${line##*'{'} |
999 | 336 |
local uuid=${line%'}'*} |
998
1b3bc0a2de41
myvbox-stop-all: added support for spaces in the response from "vboxmanage list runningvms".
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
997
diff
changeset
|
337 |
VBoxManage controlvm "$uuid" acpipowerbutton |
997
02ca7e4cc631
Added utility function for halting all VBox VMs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
993
diff
changeset
|
338 |
done |
02ca7e4cc631
Added utility function for halting all VBox VMs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
993
diff
changeset
|
339 |
} |