Migrating functions to separate source file. Commented functions will be removed on next commit
This commit is contained in:
parent
bbe0b30222
commit
34f1a5451e
199
.bash_aliases
199
.bash_aliases
@ -108,43 +108,20 @@ alias mnts='mount | column -t'
|
|||||||
# The history command but shorter
|
# The history command but shorter
|
||||||
alias h='history'
|
alias h='history'
|
||||||
|
|
||||||
|
|
||||||
##### moved to .bash_docker will be removed in next commit #####
|
|
||||||
|
|
||||||
## Lazy docker composing. Set the variable somewhere.
|
|
||||||
#alias doco="$DOCKER_COMPOSE_COMMAND"
|
|
||||||
#alias redoco="$DOCKER_COMPOSE_COMMAND down && $DOCKER_COMPOSE_COMMAND up -d"
|
|
||||||
#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"
|
|
||||||
#alias watchtower="docker run -d --restart unless-stopped --name 'watch-$(date +%H%M)' -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower "
|
|
||||||
#alias watchonce="docker run -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once"
|
|
||||||
#alias onetower="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --run-once"
|
|
||||||
#alias docport='docker container ls --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" -a'
|
|
||||||
## Regain all that space taken up by projects you abandoned
|
|
||||||
#alias docprune='echo "Pruning images"; docker image prune -f && echo "Pruning networks"; docker network prune -f && echo "Pruning containers"; docker container prune -f && echo "Pruning Volumes"; docker volume prune -f'
|
|
||||||
## 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'
|
|
||||||
#alias dps="docker ps --format 'CONTAINER ID: {{.ID}}\nIMAGE: {{.Image}}\nCOMMAND: {{.Command}}\nCREATED: {{.CreatedAt}}\nSTATUS: {{.Status}}\nPORTS: {{.Ports}}\nNAMES: {{.Names}}\n'|cat"
|
|
||||||
#alias lzd='docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v ~/lzd:/.config/jesseduffield/lazydocker lazyteam/lazydocker'
|
|
||||||
#alias doctime="docker ps --format 'CONTAINER NAME: {{.Names}}\nUPTIME: {{.Status}}'|cat"
|
|
||||||
#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'
|
|
||||||
#alias ytdlp='docker run --rm -v "/nasty/ytdl:/media" -it jauderho/yt-dlp:latest '
|
|
||||||
# Misc
|
# Misc
|
||||||
# Get the weather. Put your location after the command
|
# Get the weather. Put your location after the command
|
||||||
alias wttr='ansiweather -u imperial -s false -l'
|
alias wttr='ansiweather -u imperial -s false -l'
|
||||||
#Read the fucking manual
|
##Read the fucking manual
|
||||||
rtfm() { help $@ || info $@ || man $@ || curl "http://cheat.sh/$@"; }
|
#rtfm() { help $@ || info $@ || man $@ || curl "http://cheat.sh/$@"; }
|
||||||
# Get your public IP
|
## Get your public IP
|
||||||
extip(){ ip=$(curl -s http://api.ipify.org);
|
#extip(){ ip=$(curl -s http://api.ipify.org);
|
||||||
echo "Public IP address is $ip"
|
# echo "Public IP address is $ip"
|
||||||
}
|
#}
|
||||||
# Cheatsheet for linux commands
|
## Cheatsheet for linux commands
|
||||||
ch() { curl "http://cheat.sh/$@"; }
|
#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
|
## 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
|
||||||
notica() { curl --data "d:$*" "https://noti.toad.city/?VFvu53" ; }
|
#notica() { curl --data "d:$*" "https://noti.toad.city/?VFvu53" ; }
|
||||||
|
#
|
||||||
# A quick lil speedyboi
|
# A quick lil speedyboi
|
||||||
alias speedTest='curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -'
|
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
|
# If you're runnng my exact mastodon setup, this will be useful
|
||||||
@ -154,81 +131,81 @@ alias hackingtool='docker run -it --net=host --security-opt seccomp=unconfined -
|
|||||||
# Do you need to reboot? Find out here!
|
# Do you need to reboot? Find out here!
|
||||||
alias needrs='[ -f /var/run/reboot-required ] && echo "You need to reboot"'
|
alias needrs='[ -f /var/run/reboot-required ] && echo "You need to reboot"'
|
||||||
alias gitgraph='git log --graph --oneline --decorate'
|
alias gitgraph='git log --graph --oneline --decorate'
|
||||||
# Countdown Timer
|
## Countdown Timer
|
||||||
countdown() {
|
#countdown() {
|
||||||
start="$(( $(date '+%s') + $1))"
|
# start="$(( $(date '+%s') + $1))"
|
||||||
while [ $start -ge $(date +%s) ]; do
|
# while [ $start -ge $(date +%s) ]; do
|
||||||
time="$(( $start - $(date +%s) ))"
|
# time="$(( $start - $(date +%s) ))"
|
||||||
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
# printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
||||||
sleep 0.1
|
# sleep 0.1
|
||||||
done
|
# done
|
||||||
}
|
#}
|
||||||
# Random quote to avoid making useful commit messages
|
## Random quote to avoid making useful commit messages
|
||||||
function rgcm() {
|
#function rgcm() {
|
||||||
api="https://whatthecommit.com/index.txt"
|
# api="https://whatthecommit.com/index.txt"
|
||||||
message=$(curl -s $api)
|
# message=$(curl -s $api)
|
||||||
if [[ -z $message ]]; then
|
# if [[ -z $message ]]; then
|
||||||
echo "Error: Failed to retrieve a random commit message"
|
# echo "Error: Failed to retrieve a random commit message"
|
||||||
return 1
|
# return 1
|
||||||
fi
|
# fi
|
||||||
git add .
|
# git add .
|
||||||
git commit -m "$message"
|
# git commit -m "$message"
|
||||||
echo "Git commit submitted with message: $message"
|
# echo "Git commit submitted with message: $message"
|
||||||
}
|
#}
|
||||||
function cntdn() {
|
#function cntdn() {
|
||||||
local count=$1
|
# local count=$1
|
||||||
while [ $count -gt 0 ]; do
|
# while [ $count -gt 0 ]; do
|
||||||
echo -en "\n$count... "
|
# echo -en "\n$count... "
|
||||||
if [ $count -eq 3 ]; then
|
# if [ $count -eq 3 ]; then
|
||||||
echo "You've still got a few seconds to live it up before your time runs out!"
|
# echo "You've still got a few seconds to live it up before your time runs out!"
|
||||||
elif [ $count -eq 2 ]; then
|
# elif [ $count -eq 2 ]; then
|
||||||
echo "Tick-tock, tick-tock, time's running out!"
|
# echo "Tick-tock, tick-tock, time's running out!"
|
||||||
elif [ $count -eq 1 ]; then
|
# elif [ $count -eq 1 ]; then
|
||||||
echo "You had a good run, but it's time to face the music!"
|
# echo "You had a good run, but it's time to face the music!"
|
||||||
fi
|
# fi
|
||||||
sleep 1
|
# sleep 1
|
||||||
((count--))
|
# ((count--))
|
||||||
done
|
# done
|
||||||
echo "Time's up!"
|
# echo "Time's up!"
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
function ramdisk() {
|
#function ramdisk() {
|
||||||
if [ -z "$1" ]; then
|
# if [ -z "$1" ]; then
|
||||||
echo "Error: Ramdisk size not specified."
|
# echo "Error: Ramdisk size not specified."
|
||||||
return 1
|
# return 1
|
||||||
fi
|
# fi
|
||||||
if [ ! -d "$HOME/ramdown" ]; then
|
# if [ ! -d "$HOME/ramdown" ]; then
|
||||||
mkdir "$HOME/ramdown"
|
# mkdir "$HOME/ramdown"
|
||||||
fi
|
# fi
|
||||||
|
#
|
||||||
size="$1"
|
# size="$1"
|
||||||
|
#
|
||||||
sudo mount -t tmpfs -o size="$size" tmpfs "$HOME/ramdown"
|
# sudo mount -t tmpfs -o size="$size" tmpfs "$HOME/ramdown"
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
ipin() {
|
#ipin() {
|
||||||
local ip=$1
|
# local ip=$1
|
||||||
local endpoint="https://ipinfo.io"
|
# local endpoint="https://ipinfo.io"
|
||||||
# Append IP to the endpoint if provided
|
# # Append IP to the endpoint if provided
|
||||||
if [[ -n $ip ]]; then
|
# if [[ -n $ip ]]; then
|
||||||
endpoint+="/$ip"
|
# endpoint+="/$ip"
|
||||||
fi
|
# fi
|
||||||
endpoint+="/json?token=4ea2457429bf23"
|
# endpoint+="/json?token=4ea2457429bf23"
|
||||||
# Make the API call and prettify the JSON response
|
# # Make the API call and prettify the JSON response
|
||||||
curl -s "$endpoint" | jq .
|
# curl -s "$endpoint" | jq .
|
||||||
}
|
#}
|
||||||
# Tere function
|
## Tere function
|
||||||
tere() {
|
#tere() {
|
||||||
local result=$(command tere "$@")
|
# local result=$(command tere "$@")
|
||||||
[ -n "$result" ] && cd -- "$result"
|
# [ -n "$result" ] && cd -- "$result"
|
||||||
}
|
#}
|
||||||
# Compress files. Like the name says.
|
## Compress files. Like the name says.
|
||||||
function compress_files() {
|
#function compress_files() {
|
||||||
if [ -z "$1" ]; then
|
# if [ -z "$1" ]; then
|
||||||
echo "Usage: compress_files <archive_name.zip> <file1> <file2> ..."
|
# echo "Usage: compress_files <archive_name.zip> <file1> <file2> ..."
|
||||||
else
|
# else
|
||||||
zip -r "$1" "${@:2}"
|
# zip -r "$1" "${@:2}"
|
||||||
fi
|
# fi
|
||||||
}
|
#}
|
||||||
# See open ports
|
## See open ports
|
||||||
alias ports='netstat -tuln '
|
alias ports='netstat -tuln '
|
||||||
|
90
.bash_functions
Normal file
90
.bash_functions
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
#Read the fucking manual
|
||||||
|
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
|
||||||
|
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
|
||||||
|
notica() { curl --data "d:$*" "https://noti.toad.city/?VFvu53" ; }
|
||||||
|
|
||||||
|
# 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() {
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
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!"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ramdisk() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Error: Ramdisk size not specified."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [ ! -d "$HOME/ramdown" ]; then
|
||||||
|
mkdir "$HOME/ramdown"
|
||||||
|
fi
|
||||||
|
|
||||||
|
size="$1"
|
||||||
|
|
||||||
|
sudo mount -t tmpfs -o size="$size" tmpfs "$HOME/ramdown"
|
||||||
|
}
|
||||||
|
|
||||||
|
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 .
|
||||||
|
}
|
||||||
|
# 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
|
||||||
|
}
|
4
.bashrc
4
.bashrc
@ -136,7 +136,9 @@ fi
|
|||||||
if [ -f ~/.bash_docker ]; then
|
if [ -f ~/.bash_docker ]; then
|
||||||
. ~/.bash_docker
|
. ~/.bash_docker
|
||||||
fi
|
fi
|
||||||
|
if [ -f ~/.bash_functions ]; then
|
||||||
|
. ~/.bash_functions
|
||||||
|
fi
|
||||||
# enable programmable completion features (you don't need to enable
|
# enable programmable completion features (you don't need to enable
|
||||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||||
# sources /etc/bash.bashrc).
|
# sources /etc/bash.bashrc).
|
||||||
|
211
:b2
Normal file
211
:b2
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
# Detect distribution
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Application management
|
||||||
|
case "$ID" in
|
||||||
|
ubuntu|debian|pop)
|
||||||
|
# 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)
|
||||||
|
# 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
|
||||||
|
;;
|
||||||
|
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
|
||||||
|
|
||||||
|
# General
|
||||||
|
# Get $HOME quick
|
||||||
|
alias ~='cd ~/;clear'
|
||||||
|
# A Nice display of all files in a directory
|
||||||
|
alias ll='ls -hog'
|
||||||
|
# Above but...different I'm sure
|
||||||
|
alias lsa='ls -lah'
|
||||||
|
# List stuff sorted by size
|
||||||
|
alias lt='ls --human-readable --size -1 -S --classify'
|
||||||
|
# Grep command history fast-like
|
||||||
|
alias gh='history|grep'
|
||||||
|
# lol
|
||||||
|
alias please='sudo !!'
|
||||||
|
# sometimes it feels good
|
||||||
|
alias fucking='sudo'
|
||||||
|
# Install bat. It's better.
|
||||||
|
alias cat='bat'
|
||||||
|
# Source this very file
|
||||||
|
alias src='source ~/.bashrc'
|
||||||
|
# Big Boy edit something
|
||||||
|
alias svim='sudo vim'
|
||||||
|
# Ping but with sounds
|
||||||
|
alias ding='ping -i 5 -a'
|
||||||
|
# An extremely useful benchmark script
|
||||||
|
alias yabs='curl -sL yabs.sh | bash'
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
|
||||||
|
#opens specified command in new window in screen session
|
||||||
|
alias s='screen -X screen '
|
||||||
|
# Resume screen or create a new one named main
|
||||||
|
alias scr='screen -r || screen -S main'
|
||||||
|
# press enter to continue. Occasionally useful
|
||||||
|
alias cnfrm='read -p "Press enter to proceed" '
|
||||||
|
|
||||||
|
# A more intense ping for the professional on the go
|
||||||
|
alias pang='ping -i 10 -v -a'
|
||||||
|
# List the mounted things
|
||||||
|
alias mnts='mount | column -t'
|
||||||
|
# The history command but shorter
|
||||||
|
alias h='history'
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
# Get the weather. Put your location after the command
|
||||||
|
alias wttr='ansiweather -u imperial -s false -l'
|
||||||
|
##Read the fucking manual
|
||||||
|
#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
|
||||||
|
#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
|
||||||
|
#notica() { curl --data "d:$*" "https://noti.toad.city/?VFvu53" ; }
|
||||||
|
#
|
||||||
|
# A quick lil speedyboi
|
||||||
|
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
|
||||||
|
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
|
||||||
|
alias hackingtool='docker run -it --net=host --security-opt seccomp=unconfined --privileged blackarchlinux/blackarch:latest'
|
||||||
|
# Do you need to reboot? Find out here!
|
||||||
|
alias needrs='[ -f /var/run/reboot-required ] && echo "You need to reboot"'
|
||||||
|
alias gitgraph='git log --graph --oneline --decorate'
|
||||||
|
# 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() {
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
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!"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ramdisk() {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Error: Ramdisk size not specified."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [ ! -d "$HOME/ramdown" ]; then
|
||||||
|
mkdir "$HOME/ramdown"
|
||||||
|
fi
|
||||||
|
|
||||||
|
size="$1"
|
||||||
|
|
||||||
|
sudo mount -t tmpfs -o size="$size" tmpfs "$HOME/ramdown"
|
||||||
|
}
|
||||||
|
|
||||||
|
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 .
|
||||||
|
}
|
||||||
|
# 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 '
|
Loading…
Reference in New Issue
Block a user