148 lines
3.7 KiB
Bash
148 lines
3.7 KiB
Bash
#!/bin/bash
|
|
|
|
# aliases common to bash and zsh
|
|
|
|
# shellcheck source=../../secrets
|
|
source /home/*/setup-cockpit/secrets
|
|
alias lime2connect='ssh $SSH_REPO'
|
|
alias git-summary='~/github_misc/git-summary/git-summary'
|
|
|
|
# TALISMAN
|
|
export TALISMAN_HOME="$HOME/.talisman/bin"
|
|
alias talisman=$TALISMAN_HOME/talisman_linux_amd64
|
|
export TALISMAN_INTERACTIVE=true
|
|
|
|
# color support
|
|
if [ -x /usr/bin/dircolors ]; then
|
|
if [ -r ~/.dircolors ]; then
|
|
eval "$(dircolors -b ~/.dircolors)"
|
|
else
|
|
eval "$(dircolors -b)"
|
|
fi
|
|
alias ls='ls --color=auto'
|
|
alias grep='grep --color=auto'
|
|
alias fgrep='fgrep --color=auto'
|
|
alias egrep='egrep --color=auto'
|
|
alias diff='diff --color=auto'
|
|
alias ip='ip --color=auto'
|
|
fi
|
|
|
|
alias rm='rm -I --preserve-root'
|
|
|
|
# Add an "alert" alias for long running commands. Use like so:
|
|
# sleep 10; alert
|
|
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
|
|
|
alias weather='curl wttr.in'
|
|
|
|
alias ll='ls -lh'
|
|
alias lla='ls -lArth'
|
|
alias la='ls -A'
|
|
alias l='ls -CF'
|
|
|
|
alias envactivate='source .env/bin/activate'
|
|
alias visudo='export EDITOR=$EDITOR && sudo -E visudo'
|
|
|
|
if [ -x /usr/bin/nvim ]; then
|
|
alias vim='nvim'
|
|
fi
|
|
|
|
# For common errors
|
|
alias :q=' exit'
|
|
alias :x=' exit'
|
|
alias cd..='cd ..'
|
|
|
|
pw() {
|
|
export PASSWORD_STORE_CLIP_TIME=8
|
|
pass -c2 "$1"; sleep 5; pass -c3 "$1"; sleep 5; pass -c "$1"
|
|
unset PASSWORD_STORE_CLIP_TIME
|
|
}
|
|
|
|
clitip() {
|
|
curl -s https://raw.githubusercontent.com/jlevy/the-art-of-command-line/master/README.md |
|
|
sed '/cowsay[.]png/d' |
|
|
pandoc -f markdown -t html |
|
|
xmlstarlet fo --html --dropdtd |
|
|
xmlstarlet sel -t -v "(html/body/ul/li[count(p)>0])[$RANDOM mod last()+1]" |
|
|
xmlstarlet unesc | fmt -80 | iconv -t US
|
|
}
|
|
|
|
GIT_REPOS=(~/.password-store ~/setup-cockpit ~/keepass ~/tssr ~/lessons/* ~/personal-scripts ~/root-me ~/src/* ~/fcn-sysadmin)
|
|
|
|
cockpit() { # enable pass-like commands (ex: cockpit git push)
|
|
local start_dir="$PWD"
|
|
cd ~/setup-cockpit && "$@"
|
|
cd "$start_dir" && echo 'done'
|
|
}
|
|
|
|
system_update() {
|
|
# Don't update if its a kernel update that will require reboot
|
|
if checkupdates >/dev/null 2>&1; then
|
|
case "$(checkupdates | grep linux && echo)" in
|
|
*linux*)
|
|
echo "Not performing update"
|
|
;;
|
|
*)
|
|
sudo pacman -Syu
|
|
esac
|
|
fi
|
|
}
|
|
|
|
pull_from_repos() {
|
|
local start_dir="$PWD"
|
|
for repo in "${GIT_REPOS[@]}"; do
|
|
echo "Pulling from $repo..."
|
|
cd "$repo" && git pull
|
|
done
|
|
cd "$start_dir" || exit 1
|
|
}
|
|
|
|
hello() {
|
|
sudo protonvpn c --cc NL
|
|
system_update
|
|
|
|
echo -n "Do you want to pull from you git repos? [y/N] "
|
|
local answer
|
|
read -r answer
|
|
case "$answer" in
|
|
y)
|
|
pull_from_repos
|
|
;;
|
|
*)
|
|
echo "Not pulling from git repos."
|
|
esac
|
|
}
|
|
|
|
bye() {
|
|
sudo protonvpn d && shutdown now
|
|
}
|
|
|
|
# Use python to make simple calculations, like 'calc 24/8'
|
|
calc() {
|
|
echo -n "$* = "
|
|
python -c "print($*)"
|
|
}
|
|
|
|
# Open a map with location after using whois
|
|
whois-firefox() {
|
|
mkfifo pipe; cat pipe &
|
|
coords=$(whois "$1" | tee pipe | grep geoloc | sed -r 's/^geoloc:\s+//' | sort | uniq)
|
|
slash_coords=${coords// /\/}
|
|
firefox "https://osm.org/search?query=$coords#map=16/$slash_coords"
|
|
rm pipe
|
|
}
|
|
|
|
# Search the Arch Wiki
|
|
aw() {
|
|
firefox "https://wiki.archlinux.org/index.php?title=Special%3ASearch&search=$1" &
|
|
}
|
|
|
|
# Search Arch Packages
|
|
pkg() {
|
|
firefox "https://www.archlinux.org/packages/?sort=&maintainer=&flagged=&q=$1" &
|
|
}
|
|
|
|
# Search AUR Packages
|
|
aur() {
|
|
firefox "https://aur.archlinux.org/packages/?O=0&SeB=nd&outdated=&SB=n&SO=a&PP=50&K=$1" &
|
|
}
|