2022-02-05 22:58:21 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# some housekeeping
|
|
|
|
shopt -s autocd
|
2024-04-10 19:20:09 -05:00
|
|
|
set -o vi # vim mode
|
2022-10-18 18:19:26 -05:00
|
|
|
alias ls="ls --color=auto"
|
2023-04-10 08:58:18 -05:00
|
|
|
alias ll="ls -lah --color=auto"
|
2024-04-10 19:20:09 -05:00
|
|
|
function cd() {
|
|
|
|
builtin cd "$@" && ls --color=auto
|
|
|
|
}
|
|
|
|
|
|
|
|
# history
|
|
|
|
HISTCONTROL=ignorespace:ignoredups:erasedups
|
|
|
|
HISTFILESIZE=9999999999
|
|
|
|
HISTSIZE=9999999999
|
|
|
|
|
|
|
|
shopt -s cmdhist
|
|
|
|
shopt -s histreedit
|
|
|
|
shopt -s histappend
|
|
|
|
shopt -s histverify
|
2022-10-18 18:19:26 -05:00
|
|
|
|
2024-02-24 17:22:30 -06:00
|
|
|
PS1="\h:\w\$ "
|
2022-06-26 19:01:06 -05:00
|
|
|
|
2024-07-24 13:37:30 -05:00
|
|
|
# hostname shenanigans
|
|
|
|
case "$HOSTNAME" in
|
|
|
|
"copernicus")
|
|
|
|
PS1="\[\033[92;1m\]$PS1\[\033[0;0m\]"
|
|
|
|
;;
|
|
|
|
"x230t")
|
|
|
|
PS1="\[\033[93;1m\]$PS1\[\033[0;0m\]"
|
|
|
|
;;
|
|
|
|
"mlg")
|
|
|
|
PS1="\[\033[94;1m\]$PS1\[\033[0;0m\]"
|
|
|
|
;;
|
|
|
|
"netbox")
|
|
|
|
PS1="\[\033[95;1m\]$PS1\[\033[0;0m\]"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PS1="\[\033[96;1m\]$PS1\[\033[0;0m\]"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-06-26 19:01:06 -05:00
|
|
|
repos() {
|
|
|
|
sel="$(ls ~/git | fzy | awk '{print "/home/usr/git/"$1}')"
|
|
|
|
[ "$?" -eq 1 ] && exit
|
|
|
|
|
|
|
|
cd "$sel"
|
|
|
|
}
|
2022-10-18 18:19:26 -05:00
|
|
|
|
2024-02-24 17:22:30 -06:00
|
|
|
hist() {
|
|
|
|
res=$(cat ~/.config/bash/hist | \
|
|
|
|
sort | \
|
|
|
|
uniq | \
|
|
|
|
shuf | \
|
|
|
|
fzy)
|
|
|
|
|
|
|
|
[ -n "$res" ] && $($res)
|
|
|
|
}
|
|
|
|
|
|
|
|
search() {
|
2024-04-08 08:42:36 -05:00
|
|
|
if [ "$1" = '-a' ]; then
|
|
|
|
res=$(find /home/usr/ /home/usr/doc/ \
|
|
|
|
-mindepth 1 \
|
|
|
|
-not -path '*/.*' \
|
|
|
|
-not -path './Mail/*' \
|
|
|
|
-not -path './vdir/*' \
|
|
|
|
-not -path '*venv*' \
|
|
|
|
-not -path '*node_modules*' \
|
|
|
|
-not -path '*__pycache__*' \
|
|
|
|
-type d | cut -c 11- | fzy)
|
|
|
|
else
|
|
|
|
res=$(find $(pwd) \
|
|
|
|
-mindepth 1 \
|
|
|
|
-not -path '*/.*' \
|
|
|
|
-not -path './Mail/*' \
|
|
|
|
-not -path './vdir/*' \
|
|
|
|
-not -path '*venv*' \
|
|
|
|
-not -path '*node_modules*' \
|
|
|
|
-not -path '*__pycache__*' \
|
|
|
|
-type d | cut -c 11- | fzy)
|
|
|
|
fi
|
2024-02-24 17:22:30 -06:00
|
|
|
[ -n "$res" ] && cd /home/usr/"$res"
|
2022-11-27 13:17:51 -06:00
|
|
|
}
|