1414# -------------------------------------------------------------------------------#
1515
1616# -------------------------------------------------------------------------------#
17+ # shellcheck disable=SC2142
18+ # #Is Interactive?
19+ export BASH_IS_INTERACTIVE=" 0"
20+ case $- in
21+ * i* ) export BASH_IS_INTERACTIVE=" 1" ;;
22+ esac
1723# #Apperance
18- export TERM=" xterm-256color"
19- export EDITOR=" /usr/bin/nano"
24+ if [[ " $( tput colors 2> /dev/null | tr -d ' [:space:]' ) " -eq 256 ]]; then
25+ export TERM=" xterm-256color"
26+ fi
27+ if command -v micro & > /dev/null; then
28+ EDITOR=" $( realpath $( command -v micro) | tr -d ' [:space:]' ) "
29+ elif command -v nano & > /dev/null; then
30+ EDITOR=" $( realpath $( command -v nano) | tr -d ' [:space:]' ) "
31+ fi
32+ export EDITOR
2033# Colours
2134txtblk=' \[\e[0;30m\]' # Black - Regular
2235txtred=' \[\e[0;31m\]' # Red
@@ -92,23 +105,29 @@ export TMOUT="0"
92105BW_INTERFACE=" $( ip route | grep -i ' default' | awk ' {print $5}' | tr -d ' [:space:]' ) " && export BW_INTERFACE=" ${BW_INTERFACE} "
93106current_dir=" $( pwd) "
94107# #PATHS (Only Required)
95- export GOROOT=" ${HOME} /.go"
96- export GOPATH=" ${HOME} /go"
108+ if [[ -z " ${GOROOT} " && -d " ${HOME} /.go" ]]; then
109+ export GOROOT=" ${HOME} /.go"
110+ fi
111+ if [[ -z " ${GOPATH} " && -d " ${HOME} /go" ]]; then
112+ export GOPATH=" ${HOME} /go"
113+ fi
114+ if [[ ! -d " ${HOME} /bin" ]]; then
115+ mkdir -p " ${HOME} /bin"
116+ fi
97117export PATH=" ${HOME} /.local/share/soar/bin:${HOME} /bin:${HOME} /.cargo/bin:${HOME} /.cargo/env:${HOME} /.go/bin:${HOME} /go/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${HOME} /.local/bin:${HOME} /miniconda3/bin:${HOME} /miniconda3/condabin:/usr/local/zig:/usr/local/zig/lib:/usr/local/zig/lib/include:/usr/local/musl/bin:/usr/local/musl/lib:/usr/local/musl/include:${PATH:-/ usr/ local/ sbin:/ usr/ local/ bin:/ usr/ sbin:/ usr/ bin:/ sbin:/ bin} "
98118# -------------------------------------------------------------------------------#
99119
100-
101120# -------------------------------------------------------------------------------#
102121# #Aliases
103- if [[ -f ~ /.bash_aliases ]]; then
104- . ~ /.bash_aliases
122+ if [[ -f " ~/.bash_aliases" ]]; then
123+ . " ~/.bash_aliases"
105124fi
106- alias 7z_archive=' 7z a -t7z -mx="9" -mmt="$(($(nproc)+1))" -bsp1 -bt $1 $2'
107125alias apptainer_run=' unshare -r apptainer run --allow-setuid --keep-privs --writable'
108126alias bat=' batcat'
109127alias benchmarkQ=' curl -qfsSL bench.sh | bash'
110128alias benchmarkX=' curl -qfsSL yabs.sh | bash -s -- -i'
111129alias cf_warp_trace=' echo ; curl -qfsSL "https://1.1.1.1/cdn-cgi/trace" ; echo'
130+ alias clean_buildenv=' unset AR AS CC CFLAGS CPP CXX CPPFLAGS CXXFLAGS DLLTOOL HOST_CC HOST_CXX LD LDFLAGS LIBS NM OBJCOPY OBJDUMP RANLIB READELF SIZE STRINGS STRIP SYSROOT'
112131# alias df='duf'
113132alias dir=' dir --color=auto'
114133alias docker_purge=' docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi $(docker images -q) -f'
@@ -119,7 +138,8 @@ alias fdfind='fd'
119138alias fgrep=' fgrep --color=auto'
120139alias file_size=' stat -c "%s" "$1" "$2" | numfmt --to="iec" --suffix="B"'
121140alias grep=' grep --color=auto'
122- alias history_purge=' history -c 2>/dev/null ; rm -rf "$HOME/.bash_history"'
141+ alias history_purge=' history -c 2>/dev/null ; rm -rf "${HOME}/.bash_history"'
142+ alias history_purge_root=' sudo history -c 2>/dev/null ; sudo rm -rf "/root/.bash_history" 2>/dev/null'
123143alias ip_ifconfig=' ip -a -d -h -p -s address'
124144alias ip_ifconfig_resolve=' ip -a -d -h -p -r -s address'
125145alias ip_ifconfig_netconf=' ip -a -d -h -p -s netconf'
@@ -131,6 +151,8 @@ alias ls_ports_progs='sudo netstat -atulpen'
131151alias ls_ports_ip=' sudo lsof -i -l -R -n'
132152alias list_ports_netstat=' sudo netstat -atulpen'
133153alias list_procs=' sudo ps aux'
154+ alias max_procs=' echo "$(($(nproc)+1))"'
155+ alias max_threads=' echo "$(($(nproc)+1))"'
134156alias miniserve_dl=' miniserve --port 9977 --title "Files" --header "Miniserved: yes" --color-scheme-dark monokai --hide-theme-selector --qrcode --show-wget-footer --hide-version-footer --verbose'
135157alias miniserve_up=' miniserve --port 9977 --title "Files" --header "Miniserved: yes" --color-scheme-dark monokai --hide-theme-selector --qrcode --show-wget-footer --hide-version-footer --upload-files --verbose'
136158alias my_ipv4=' curl --ipv4 -qfsSL "http://ipv4.whatismyip.akamai.com" ; echo'
160182# -------------------------------------------------------------------------------#
161183
162184# -------------------------------------------------------------------------------#
163- # Functions
185+ # #Functions
186+ function 7z_archive()
187+ {
188+ 7z a -t7z -mx=" 9" -mmt=" $(( $(nproc)+ 1 )) " -bsp1 -bt " $1 " " $2 "
189+ }
190+ export -f 7z_archive
191+ function install_soar()
192+ {
193+ if [[ ! -d " ${HOME} /bin" ]]; then
194+ mkdir -p " ${HOME} /bin"
195+ fi
196+ bash <( curl -qfsSL " https://raw.githubusercontent.com/pkgforge/soar/refs/heads/main/install.sh" )
197+ command -v soar & > /dev/null || return 1
198+ if [[ ! -s " ${HOME} /.config/soar/config.toml" ]]; then
199+ soar defconfig --external
200+ fi
201+ soar sync
202+ }
203+ export -f install_soar
204+ function install_soar_force()
205+ {
206+ if [[ ! -d " ${HOME} /bin" ]]; then
207+ mkdir -p " ${HOME} /bin"
208+ fi
209+ rm -rvf " ${HOME} /.config/soar" " ${HOME} /.local/share/soar" 2> /dev/null
210+ bash <( curl -qfsSL " https://raw.githubusercontent.com/pkgforge/soar/refs/heads/main/install.sh" )
211+ command -v soar & > /dev/null || return 1
212+ soar defconfig --external
213+ soar sync
214+ }
215+ export -f install_soar_force
216+ function nixbuild_cleanup()
217+ {
218+ nix-collect-garbage
219+ nix-store --gc
220+ }
221+ export -f nixbuild_cleanup
222+ function nixbuild_info()
223+ {
224+ echo -e " \n"
225+ nix-instantiate --eval --expr " builtins.toJSON (with import <nixpkgs> {}; $1 .meta)" --quiet 2> /dev/null | jq -r fromjson 2> /dev/null
226+ echo -e " \n"
227+ }
228+ export -f nixbuild_info
229+ function nixbuild_static()
230+ {
231+ nix-build ' <nixpkgs>' --impure --attr " pkgsStatic.$1 " --cores " $(( $(nproc)+ 1 )) " --max-jobs " $(( $(nproc)+ 1 )) " --log-format bar-with-logs --out-link " ./NIX_BUILD"
232+ }
233+ export -f nixbuild_static
234+ function strip_debug()
235+ {
236+ objcopy --remove-section=" .comment" --remove-section=" .note.*" " $1 " 2> /dev/null
237+ strip --strip-debug --strip-dwo --strip-unneeded " $1 " 2> /dev/null
238+ }
239+ export -f strip_debug
240+ # -------------------------------------------------------------------------------#
241+
242+ # -------------------------------------------------------------------------------#
243+ # #GIT
244+ if [[ " ${BASH_IS_INTERACTIVE} " == 0 ]]; then
245+ export GH_PAGER=" "
246+ export GIT_TERMINAL_PROMPT=" 0"
247+ export GIT_ASKPASS=" /bin/echo"
248+ fi
164249# -------------------------------------------------------------------------------#
165250
166251# -------------------------------------------------------------------------------#
@@ -177,6 +262,20 @@ export HISTTIMEFORMAT="[${USER}, %F %T] "
177262# Check the window size after each command and, if necessary,
178263# update the values of LINES and COLUMNS.
179264shopt -s checkwinsize
265+ # Turn on ../**/*.ext Globs
266+ shopt -q -s extglob
267+ # -------------------------------------------------------------------------------#
268+
269+ # -------------------------------------------------------------------------------#
270+ # #Nix
271+ if [[ -f " /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]]; then
272+ source " /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" & > /dev/null
273+ if command -v nix & > /dev/null; then
274+ export NIXPKGS_ALLOW_BROKEN=" 1"
275+ export NIXPKGS_ALLOW_UNFREE=" 1"
276+ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=" 1"
277+ fi
278+ fi
180279# -------------------------------------------------------------------------------#
181280
182281# -------------------------------------------------------------------------------#
@@ -186,3 +285,16 @@ if command -v awk &>/dev/null && command -v sed &>/dev/null; then
186285fi
187286export PATH
188287# -------------------------------------------------------------------------------#
288+
289+ # -------------------------------------------------------------------------------#
290+ # #FZF
291+ if [[ " ${NO_FZF} " != 1 && " $( command -v bat) " && " $( command -v fd) " && " $( command -v fzf) " && " $( command -v tree) " ]]; then
292+ export FZF_DEFAULT_COMMAND=' fd --type f --hidden --follow --exclude .git'
293+ # export FZF_DEFAULT_OPTS='--no-height --color=bg+:#343d46,gutter:-1,pointer:#ff3c3c,info:#0dbc79,hl:#0dbc79,hl+:#23d18b'
294+ export FZF_CTRL_T_COMMAND=" ${FZF_DEFAULT_COMMAND} "
295+ export FZF_CTRL_T_OPTS=" --preview 'bat --color=always --line-range :50 {}'"
296+ export FZF_ALT_C_COMMAND=' fd --type d "." --hidden --exclude .git'
297+ export FZF_ALT_C_OPTS=" --preview 'tree -C {} | head -50'"
298+ eval " $( fzf --bash) "
299+ fi
300+ # -------------------------------------------------------------------------------#
0 commit comments