-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
executable file
·212 lines (171 loc) · 5.3 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
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
#
# ~/.bashrc
#
configSSH() {
eval "$(ssh-agent)"
ssh-add ~/.ssh/id_github
}
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
[[ -f ~/.welcome_screen ]] && . ~/.welcome_screen
_set_my_PS1() {
PS1='[\u@\h \W]\$ '
if [ "$(whoami)" = "liveuser" ] ; then
local iso_version="$(grep ^VERSION= /usr/lib/endeavouros-release 2>/dev/null | cut -d '=' -f 2)"
if [ -n "$iso_version" ] ; then
local prefix="eos-"
local iso_info="$prefix$iso_version"
PS1="[\u@$iso_info \W]\$ "
fi
fi
}
_set_my_PS1
unset -f _set_my_PS1
ShowInstallerIsoInfo() {
local file=/usr/lib/endeavouros-release
if [ -r $file ] ; then
cat $file
else
echo "Sorry, installer ISO info is not available." >&2
fi
}
alias ls='ls --color=auto'
alias ll='ls -lav --ignore=..' # show long listing of all except ".."
alias l='ls -lav --ignore=.?*' # show long listing but no hidden dotfiles except "."
[[ "$(whoami)" = "root" ]] && return
[[ -z "$FUNCNEST" ]] && export FUNCNEST=100 # limits recursive functions, see 'man bash'
## Use the up and down arrow keys for finding a command in history
## (you can write some initial letters of the command first).
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
################################################################################
## Some generally useful functions.
## Consider uncommenting aliases below to start using these functions.
_GeneralCmdCheck() {
# A helper for functions UpdateArchPackages and UpdateAURPackages.
echo "$@" >&2
"$@" || {
echo "Error: '$*' failed." >&2
exit 1
}
}
_CheckInternetConnection() {
# curl --silent --connect-timeout 8 https://8.8.8.8 >/dev/null
eos-connection-checker
local result=$?
test $result -eq 0 || echo "No internet connection!" >&2
return $result
}
_CheckArchNews() {
local conf=/etc/eos-update-notifier.conf
if [ -z "$CheckArchNewsForYou" ] && [ -r $conf ] ; then
source $conf
fi
if [ "$CheckArchNewsForYou" = "yes" ] ; then
local news="$(yay -Pw)"
if [ -n "$news" ] ; then
echo "Arch news:" >&2
echo "$news" >&2
echo "" >&2
# read -p "Press ENTER to continue (or Ctrl-C to stop): "
else
echo "No Arch news." >&2
fi
fi
}
UpdateArchPackages() {
# Updates Arch packages.
_CheckInternetConnection || return 1
_CheckArchNews
#local updates="$(yay -Qu --repo)"
local updates="$(checkupdates)"
if [ -n "$updates" ] ; then
echo "Updates from upstream:" >&2
echo "$updates" | sed 's|^| |' >&2
_GeneralCmdCheck sudo pacman -Syu "$@"
return 0
else
echo "No upstream updates." >&2
return 1
fi
}
UpdateAURPackages() {
# Updates AUR packages.
_CheckInternetConnection || return 1
local updates
if [ -x /usr/bin/yay ] ; then
updates="$(yay -Qua)"
if [ -n "$updates" ] ; then
echo "Updates from AUR:" >&2
echo "$updates" | sed 's|^| |' >&2
_GeneralCmdCheck yay -Syua "$@"
else
echo "No AUR updates." >&2
fi
else
echo "Warning: /usr/bin/yay does not exist." >&2
fi
}
UpdateAllPackages() {
# Updates all packages in the system.
# Upstream (i.e. Arch) packages are updated first.
# If there are Arch updates, you should run
# this function a second time to update
# the AUR packages too.
UpdateArchPackages || UpdateAURPackages
}
_open_files_for_editing() {
# Open any given document file(s) for editing (or just viewing).
# Note1: Do not use for executable files!
# Note2: uses mime bindings, so you may need to use
# e.g. a file manager to make some file bindings.
if [ -x /usr/bin/exo-open ] ; then
echo "exo-open $*" >&2
/usr/bin/exo-open "$@" >& /dev/null &
return
fi
if [ -x /usr/bin/xdg-open ] ; then
for file in "$@" ; do
echo "xdg-open $file" >&2
/usr/bin/xdg-open "$file" >& /dev/null &
done
return
fi
echo "Sorry, none of programs [$progs] is found." >&2
echo "Tip: install one of packages" >&2
for prog in $progs ; do
echo " $(pacman -Qqo "$prog")" >&2
done
}
_Pacdiff() {
local differ pacdiff=/usr/bin/pacdiff
if [ -n "$(echo q | DIFFPROG=diff $pacdiff)" ] ; then
for differ in kdiff3 meld diffuse ; do
if [ -x /usr/bin/$differ ] ; then
DIFFPROG=$differ su-c_wrapper $pacdiff
break
fi
done
fi
}
gtex() {
cd ~/snap/exercism/5/exercism
}
nvimconfig() {
nvim ~/.config/nvim/init.vim
}
#------------------------------------------------------------
## Aliases for the functions above.
## Uncomment an alias if you want to use it.
##
# alias ef='_open_files_for_editing' # 'ef' opens given file(s) for editing
# alias pacdiff=_Pacdiff
################################################################################
source /usr/share/nvm/init-nvm.sh
. "$HOME/.cargo/env"
# Variabl exports
#export GOPATH=$HOME/go
#export GOROOT=/usr/lib/go
#export PATH=$PATH:$GOPATH
#export PATH=$PATH:/usr/local/go/bin
#export PATH=$PATH:$GOROOT/bin:$GOPATH/bin