2022-06-01 13:01:07 +00:00
|
|
|
|
test -n "$PS1" || return 0
|
|
|
|
|
|
2023-11-07 09:58:02 +00:00
|
|
|
|
which pfetch >/dev/null 2>&1 && pfetch
|
|
|
|
|
|
2023-01-31 17:33:04 +00:00
|
|
|
|
test $(id -u) -eq 0 || sudo=sudo
|
|
|
|
|
|
2023-04-27 12:28:04 +00:00
|
|
|
|
alias jc="$sudo journalctl --boot --unit"
|
2023-01-31 17:33:04 +00:00
|
|
|
|
alias sc="$sudo systemctl"
|
|
|
|
|
alias scs="$sudo systemctl status"
|
|
|
|
|
alias sce="$sudo systemctl enable --now"
|
|
|
|
|
alias sced="$sudo --preserve-env=EDITOR systemctl edit"
|
2023-02-07 12:19:34 +00:00
|
|
|
|
alias scr="$sudo systemctl daemon-reload && $sudo systemctl reload-or-restart"
|
2023-01-31 17:33:04 +00:00
|
|
|
|
|
2023-07-27 15:16:41 +00:00
|
|
|
|
alias hist='history | less'
|
|
|
|
|
alias m='mv -vi'
|
|
|
|
|
|
2024-01-12 16:54:15 +00:00
|
|
|
|
alias nginx-edit="sudo vi /etc/nginx/nginx.conf && nginx -t && sudo systemctl reload nginx"
|
|
|
|
|
|
2023-11-15 19:49:25 +00:00
|
|
|
|
# Fast Find
|
|
|
|
|
ff() {
|
|
|
|
|
name=$1
|
|
|
|
|
shift
|
|
|
|
|
$(command -v fd || echo fdfind) --hidden "$name" ||
|
|
|
|
|
find "$@" -name "*$name*"
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 16:54:15 +00:00
|
|
|
|
xtrace () {
|
|
|
|
|
set -x
|
|
|
|
|
"$@"
|
|
|
|
|
set +x
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-31 17:33:04 +00:00
|
|
|
|
highlight() { echo "[4m$1[0m"; }
|
|
|
|
|
status() {
|
|
|
|
|
highlight 'System'
|
|
|
|
|
free -h
|
|
|
|
|
df -h -T --exclude-type=tmpfs --exclude-type=devtmpfs --exclude-type=squashfs --exclude-type=overlay
|
|
|
|
|
zfs list -d 0
|
2023-06-12 09:08:37 +00:00
|
|
|
|
sudo certbot certificates
|
2023-01-31 17:33:04 +00:00
|
|
|
|
highlight 'Internet'
|
|
|
|
|
#--color=always
|
|
|
|
|
ip -brief address | grep --color=none -E '^(wl|en|tun|vmbr)'
|
|
|
|
|
ip route
|
|
|
|
|
echo -n 'IPv4: ' && timeout 3s ping example.com -A -c 3 -w 3 -q -4
|
|
|
|
|
echo -n 'IPv6: ' && timeout 3s ping example.com -A -c 3 -w 3 -q -6
|
|
|
|
|
highlight 'Programs'
|
|
|
|
|
tmux ls
|
|
|
|
|
$sudo systemctl --no-pager list-units --failed || service --status-all
|
|
|
|
|
if type docker >/dev/null
|
|
|
|
|
then $sudo docker ps || $sudo systemctl status docker
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 06:35:48 +00:00
|
|
|
|
__u="$sudo apt update && $sudo apt upgrade"
|
|
|
|
|
alias u="$__u"
|
|
|
|
|
alias ur="tmux new-session -s upgrade '$__u && $sudo reboot'"
|
2022-12-22 14:44:02 +00:00
|
|
|
|
|
|
|
|
|
# Diff recursively
|
2022-05-03 09:21:33 +00:00
|
|
|
|
difr() { diff --color=always --unified=1 --recursive "$@" | less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen; }
|
2022-12-22 14:44:02 +00:00
|
|
|
|
# Copy recursively with rsync
|
|
|
|
|
alias rc='rsync --recursive --info=progress2,remove,symsafe,flist,del --human-readable --links --hard-links --times'
|
2022-05-03 09:21:33 +00:00
|
|
|
|
|
2023-01-05 09:37:25 +00:00
|
|
|
|
export LESS="--RAW-CONTROL-CHARS --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
|
|
|
|
|
|
2022-02-12 08:37:37 +00:00
|
|
|
|
# ls aliases
|
2020-03-08 18:58:52 +00:00
|
|
|
|
|
2023-03-31 17:11:13 +00:00
|
|
|
|
export LS_OPTIONS='--human-readable --si --group-directories-first --dereference-command-line'
|
2022-02-12 08:37:37 +00:00
|
|
|
|
eval "$(dircolors)"
|
|
|
|
|
alias ls='ls --color=auto'
|
2023-03-31 17:11:13 +00:00
|
|
|
|
alias ll='ls $LS_OPTIONS --file-type -l'
|
|
|
|
|
alias la='ll --all'
|
2022-02-12 08:37:37 +00:00
|
|
|
|
alias l='ls $LS_OPTIONS --color=always --almost-all'
|
2023-01-04 04:33:49 +00:00
|
|
|
|
|
2022-05-24 07:24:51 +00:00
|
|
|
|
which bat >/dev/null 2>&1 || alias bat="$(which batcat >/dev/null 2>&1 && echo batcat || echo less -FX)"
|
2022-05-03 09:21:33 +00:00
|
|
|
|
b() { test -d "${1:-.}" && l "$@" || bat "$@"; }
|
2023-01-04 04:33:49 +00:00
|
|
|
|
|
2022-05-24 07:24:51 +00:00
|
|
|
|
alias v="$(which nvim >/dev/null 2>&1 && echo nvim || echo ${EDITOR:-vi})"
|
2023-01-04 04:33:49 +00:00
|
|
|
|
alias h=man
|
2022-04-12 17:00:30 +00:00
|
|
|
|
|
|
|
|
|
# Grep aliases
|
|
|
|
|
|
|
|
|
|
# Default grep with some niceties
|
|
|
|
|
alias grpc='grep --color=auto --line-number --binary-files=without-match --directories=skip'
|
|
|
|
|
# Default grep with some niceties and ignoring case
|
|
|
|
|
alias grp='grpc --ignore-case'
|
|
|
|
|
# Grep recursively and paginate
|
|
|
|
|
grpr() { grp --color=always --recursive $(echo $DIRS_IGNORE | sed 's/-x/--exclude-dir/g') "$@" | less -FX; }
|
2021-12-11 01:31:06 +00:00
|
|
|
|
|
2022-02-12 08:37:37 +00:00
|
|
|
|
# Some aliases to avoid making mistakes:
|
2020-03-08 18:58:52 +00:00
|
|
|
|
|
2022-02-12 08:37:37 +00:00
|
|
|
|
alias rm='rm -I'
|
|
|
|
|
alias cp='cp -i'
|
|
|
|
|
alias mv='mv -i'
|
2020-03-08 18:58:52 +00:00
|
|
|
|
|
2023-01-18 01:02:56 +00:00
|
|
|
|
# Completion and Extras
|
2023-01-05 09:37:25 +00:00
|
|
|
|
|
|
|
|
|
src() { test -f "$1" && source "$1"; }
|
|
|
|
|
|
|
|
|
|
case $(readlink /proc/$$/exe) in (*bash)
|
|
|
|
|
bind '"\ek":history-search-backward'
|
|
|
|
|
bind '"\ej":history-search-forward'
|
|
|
|
|
|
|
|
|
|
shopt -oq posix || src /etc/bash_completion
|
|
|
|
|
|
2020-03-08 18:58:52 +00:00
|
|
|
|
# Fancy prompt
|
2022-02-12 08:37:37 +00:00
|
|
|
|
PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]"
|
2020-03-08 18:58:52 +00:00
|
|
|
|
PS1="$PS1 \`if [ \$? = 0 ]; then echo -e '\[\033[01;32m\]:)';"
|
2022-02-12 08:37:37 +00:00
|
|
|
|
PS1="$PS1 else echo -e '\[\033[01;31m\]' \$?; fi\`\[\033[00m\]"
|
2023-01-05 09:37:25 +00:00
|
|
|
|
;;
|
|
|
|
|
(*zsh) setopt sh_word_split;;
|
|
|
|
|
esac
|
2022-02-12 08:37:37 +00:00
|
|
|
|
|
|
|
|
|
src /usr/share/git/completion/git-prompt.sh && PS1="$PS1\$(__git_ps1 \" (%s)\")"
|
|
|
|
|
src $HOME/.config/shell/functions
|
|
|
|
|
|
|
|
|
|
PS1="$PS1 \$ "
|