configs/.bash_aliases

228 lines
8.1 KiB
Bash
Raw Normal View History

2023-04-01 19:19:02 +00:00
# Detect distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
fi
2021-05-19 07:03:21 +00:00
# Application management
2023-04-01 19:19:02 +00:00
case "$ID" in
ubuntu|debian)
# Install something bypassing the prompts
alias inst='sudo apt-get install -y'
# Do a basic update
alias update='sudo apt-get update -y && sudo apt-get upgrade -y'
# Upgrade everything
alias upgrade_all='sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get autoclean -y && sudo apt-get --with-new-pkgs upgrade -y'
# Search packages
alias pacs='apt-cache search'
# Uninstall
alias burn='sudo apt-get autoremove'
;;
arch|archlinux)
2023-04-01 20:11:44 +00:00
# Check if yay is installed
if command -v yay >/dev/null 2>&1; then
# Install something bypassing the prompts
alias inst='yay -S --noconfirm'
# Do a basic update
alias update='yay -Syu --noconfirm'
# Upgrade everything
alias upgrade_all='yay -Syu --noconfirm && yay -Rns $(pacman -Qdtq) --noconfirm && sudo paccache -r'
# Search packages
alias pacs='yay -Ss'
# Uninstall
alias burn='yay -Rns --noconfirm'
else
# Install something bypassing the prompts
alias inst='sudo pacman -S --noconfirm'
# Do a basic update
alias update='sudo pacman -Syu --noconfirm'
# Upgrade everything
alias upgrade_all='sudo pacman -Syu --noconfirm && sudo pacman -Rns $(pacman -Qdtq) --noconfirm && sudo paccache -r'
# Search packages
alias pacs='pacman -Ss'
# Uninstall
alias burn='sudo pacman -Rns --noconfirm'
fi
2023-04-01 19:19:02 +00:00
;;
alpine)
# Install something bypassing the prompts
alias inst='sudo apk add'
# Do a basic update
alias update='sudo apk update && sudo apk upgrade'
# Upgrade everything
alias upgrade_all='sudo apk update && sudo apk upgrade && sudo apk cache clean'
# Search packages
alias pacs='apk search'
# Uninstall
alias burn='sudo apk del'
;;
*)
# Add any other distribution-specific aliases here
;;
esac
2021-05-18 18:14:51 +00:00
2021-05-19 07:03:21 +00:00
# General
# Get $HOME quick
2023-12-13 01:33:49 +00:00
alias ~='cd ~/;clear'
# A Nice display of all files in a directory
2023-01-12 06:17:23 +00:00
alias ll='ls -hog'
# Above but...different I'm sure
2021-05-18 18:14:51 +00:00
alias lsa='ls -lah'
# List stuff sorted by size
2021-05-18 18:14:51 +00:00
alias lt='ls --human-readable --size -1 -S --classify'
# Grep command history fast-like
2021-05-18 18:14:51 +00:00
alias gh='history|grep'
# lol
2023-11-25 21:33:48 +00:00
alias please='sudo !!'
# sometimes it feels good
2021-06-02 19:41:20 +00:00
alias fucking='sudo'
# Install bat. It's better.
2023-03-31 06:51:23 +00:00
alias cat='bat'
# Source this very file
alias src='source ~/.bashrc'
# Big Boy edit something
2022-08-01 18:03:26 +00:00
alias svim='sudo vim'
# Ping but with sounds
alias ding='ping -i 5 -a'
# An extremely useful benchmark script
2022-09-19 22:56:31 +00:00
alias yabs='curl -sL yabs.sh | bash'
2021-05-18 18:14:51 +00:00
2021-05-19 07:03:21 +00:00
# Utilities
# A faster way to do the thing it does
alias sysres='sudo systemctl restart'
# This one too
alias sysup='sudo systemctl enable --now'
# Also this one
alias sysdn='sudo systemctl disable --now'
2023-01-14 21:38:14 +00:00
#opens specified command in new window in screen session
2023-10-17 22:46:08 +00:00
alias s='screen -X screen '
2023-08-22 23:54:22 +00:00
# Resume screen or create a new one named main
alias scr='screen -r || screen -S main'
2023-01-14 21:41:50 +00:00
# press enter to continue. Occasionally useful
alias cnfrm='read -p "Press enter to proceed" '
2023-01-14 21:38:14 +00:00
# A more intense ping for the professional on the go
2021-05-19 07:03:21 +00:00
alias pang='ping -i 10 -v -a'
# List the mounted things
2021-05-19 07:03:21 +00:00
alias mnts='mount | column -t'
# The history command but shorter
2021-05-24 18:11:13 +00:00
alias h='history'
2023-05-15 06:39:59 +00:00
# Lazy docker composing. Set the variable somewhere.
alias doco="$DOCKER_COMPOSE_COMMAND"
alias redoco="$DOCKER_COMPOSE_COMMAND down && $DOCKER_COMPOSE_COMMAND up -d"
2023-07-09 23:18:29 +00:00
alias redog="$DOCKER_COMPOSE_COMMAND down && $DOCKER_COMPOSE_COMMAND up -d; $DOCKER_COMPOSE_COMMAND logs -f"
alias dolog="$DOCKER_COMPOSE_COMMAND up -d; $DOCKER_COMPOSE_COMMAND logs -f"
2023-12-09 00:38:06 +00:00
alias watchtower="docker run -d --name watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --restart unless-stopped"
# Regain all that space taken up by projects you abandoned
2022-08-01 18:03:26 +00:00
alias docprune='docker image prune && docker network prune && docker container prune && docker volume prune'
# Send things instantly to a pastebin. Pipe other commands into this to share their output.
alias bin='nc termbin.com 9999'
# Quicker Docker exec
alias dex='docker exec'
2023-05-10 06:30:21 +00:00
alias dps="docker ps --format 'CONTAINER ID: {{.ID}}\nIMAGE: {{.Image}}\nCOMMAND: {{.Command}}\nCREATED: {{.CreatedAt}}\nSTATUS: {{.Status}}\nPORTS: {{.Ports}}\nNAMES: {{.Names}}\n'|cat"
2023-05-15 06:39:59 +00:00
alias lzd='docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v ~/lzd:/.config/jesseduffield/lazydocker lazyteam/lazydocker'
2023-11-18 05:19:16 +00:00
alias glance='docker run --rm -e TZ="${TZ}" -v /var/run/docker.sock:/var/run/docker.sock:ro -v /run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro --pid host --network host -it nicolargo/glances:latest-full'
2023-11-24 22:05:34 +00:00
alias ytdlp='docker run --rm -v "/nasty/ytdl:/media" -it jauderho/yt-dlp:latest '
2021-05-19 07:03:21 +00:00
# Misc
# Get the weather. Put your location after the command
alias wttr='ansiweather -u imperial -s false -l'
#Read the fucking manual
2021-05-24 18:08:29 +00:00
rtfm() { help $@ || info $@ || man $@ || curl "http://cheat.sh/$@"; }
# Get your public IP
extip(){ ip=$(curl -s http://api.ipify.org);
echo "Public IP address is $ip"
}
# Cheatsheet for linux commands
2021-06-02 19:53:58 +00:00
ch() { curl "http://cheat.sh/$@"; }
# You can go to noti.toad.city and generate your own code to get browser notifications. It's all explained there. You'll need to modify this value
2022-08-01 18:03:26 +00:00
notica() { curl --data "d:$*" "https://noti.toad.city/?VFvu53" ; }
# A quick lil speedyboi
2022-11-15 01:17:33 +00:00
alias speedTest='curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -'
# If you're runnng my exact mastodon setup, this will be useful
2022-12-05 06:05:00 +00:00
alias tootctl='docker exec -it -w /app/www mastodon bin/tootctl'
# HAHAHA Go for it. Hours of fun and profit or ruining all your stuff
2023-03-06 01:47:32 +00:00
alias hackingtool='docker run -it --net=host --security-opt seccomp=unconfined --privileged blackarchlinux/blackarch:latest'
2023-01-14 21:38:14 +00:00
# Do you need to reboot? Find out here!
2023-01-13 06:47:07 +00:00
alias needrs='[ -f /var/run/reboot-required ] && echo "You need to reboot"'
2023-11-24 22:05:34 +00:00
alias gitgraph='git log --graph --oneline --decorate'
2023-02-13 08:29:06 +00:00
# Countdown Timer
countdown() {
start="$(( $(date '+%s') + $1))"
while [ $start -ge $(date +%s) ]; do
time="$(( $start - $(date +%s) ))"
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
sleep 0.1
done
}
# Random quote to avoid making useful commit messages
function rgcm() {
2023-02-26 11:51:31 +00:00
api="https://whatthecommit.com/index.txt"
message=$(curl -s $api)
if [[ -z $message ]]; then
echo "Error: Failed to retrieve a random commit message"
return 1
fi
git add .
git commit -m "$message"
echo "Git commit submitted with message: $message"
}
2023-03-10 17:44:20 +00:00
function cntdn() {
local count=$1
while [ $count -gt 0 ]; do
echo -en "\n$count... "
if [ $count -eq 3 ]; then
echo "You've still got a few seconds to live it up before your time runs out!"
elif [ $count -eq 2 ]; then
echo "Tick-tock, tick-tock, time's running out!"
elif [ $count -eq 1 ]; then
echo "You had a good run, but it's time to face the music!"
fi
sleep 1
((count--))
done
echo "Time's up!"
}
2023-05-31 16:44:25 +00:00
function ramdisk() {
2023-05-31 16:48:42 +00:00
if [ -z "$1" ]; then
echo "Error: Ramdisk size not specified."
return 1
fi
2023-05-31 16:44:25 +00:00
if [ ! -d "$HOME/ramdown" ]; then
mkdir "$HOME/ramdown"
fi
size="$1"
sudo mount -t tmpfs -o size="$size" tmpfs "$HOME/ramdown"
}
2023-06-18 00:10:11 +00:00
ipin() {
local ip=$1
local endpoint="https://ipinfo.io"
# Append IP to the endpoint if provided
if [[ -n $ip ]]; then
endpoint+="/$ip"
fi
endpoint+="/json?token=4ea2457429bf23"
# Make the API call and prettify the JSON response
curl -s "$endpoint" | jq .
}
2023-08-05 05:14:45 +00:00
# Tere function
tere() {
local result=$(command tere "$@")
[ -n "$result" ] && cd -- "$result"
}
# Compress files. Like the name says.
function compress_files() {
if [ -z "$1" ]; then
echo "Usage: compress_files <archive_name.zip> <file1> <file2> ..."
else
zip -r "$1" "${@:2}"
fi
}
# See open ports
alias ports='netstat -tuln '