void

- enter the void 🪐
git clone git://git.acid.vegas/archlinux.git
Log | Files | Refs | Archive

bash_functions (2858B)

      1 #!/bin/bash
      2 # .bash_functions - developed by acidvegas (https://git.acid.vegas/void)
      3 
      4 cheat() {
      5 	curl cht.sh/$1
      6 }
      7 
      8 color() {
      9 	for color in {0..255}; do
     10 		printf "\e[48;5;%sm  %3s  \e[0m" $color $color
     11 		if [ $((($color + 1) % 6)) == 4 ]; then
     12 			echo
     13 		fi
     14 	done
     15 }
     16 
     17 cctain() {
     18 	NAME=$1
     19 	incus storage create $NAME-pool dir
     20 	incus launch images:debian/12 $NAME-container -s $NAME-pool
     21 	incus config set $NAME-container boot.autostart true
     22 	sleep 10 # Delay to allow the container to start and get an IP address from the DHCP server
     23 	incus exec $NAME-container -- apt update  -y
     24 	incus exec $NAME-container -- apt upgrade -y
     25 	incus exec $NAME-container -- apt install -y git nano unattended-upgrades wget
     26 	incus exec $NAME-container -- useradd -m -s /bin/bash agent
     27 	incus exec $NAME-container -- journalctl --vacuum-time=1d
     28 	incus exec $NAME-container -- sh -c 'printf "[Journal]\nStorage=volatile\nSplitMode=none\nRuntimeMaxUse=500K" > /etc/systemd/journald.conf'
     29 	incus exec $NAME-container -- systemctl restart systemd-journald
     30 }
     31 
     32 fkill() {
     33 	local pid
     34 	if [ "$UID" != "0" ]; then
     35 		pid=$(ps -f -u $UID | sed 1d | fzf -m | awk '{print $2}')
     36 	else
     37 		pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
     38 	fi
     39 	if [ "x$pid" != "x" ]; then
     40 		echo $pid | xargs kill -${1:-9}
     41 	fi
     42 }
     43 
     44 extract() {
     45 	if [ ! -z "$1" ]; then
     46 		if [ -f $1 ]; then
     47 			case $1 in
     48 				*.tar.bz2) tar xvjf $1	  ;;
     49 				*.tar.gz)  tar xvzf $1    ;;
     50 				*.tar.xz)  tar xvJf $1    ;;
     51 				*.lzma)    unlzma $1      ;;
     52 				*.bz2)     bunzip2 $1     ;;
     53 				*.rar)     unrar x -ad $1 ;;
     54 				*.gz)      gunzip $1      ;;
     55 				*.tar)     tar xvf $1     ;;
     56 				*.tbz2)    tar xvjf $1    ;;
     57 				*.tgz)     tar xvzf $1    ;;
     58 				*.zip)     unzip $1       ;;
     59 				*.Z)       uncompress $1  ;;
     60 				*.7z)      7z x $1        ;;
     61 				*.xz)      unxz $1        ;;
     62 				*)         echo "$1 - unknown archive format" ;;
     63 			esac
     64 		else
     65 			echo "$1 - file does not exist"
     66 		fi
     67 	fi
     68 }
     69 
     70 flash() {
     71 	sudo dd bs=4M if=$1 of=$2 status=progress
     72 	sudo /bin/sync
     73 }
     74 
     75 gcp() {
     76 	git add . && git commit -S -m "$*" && git push
     77 }
     78 
     79 hf() {
     80 	curl -F file=@$1 https://hardfiles.org/ # yeah thats right motherfucker, real bay shit, for real bay motherfuckers.
     81 }
     82 
     83 mntusb() {
     84 	sudo mount $1 /mnt -o uid=$(id -u),gid=$(id -g)
     85 }
     86 
     87 repo() {
     88 	if [ ! -z "$1" ]; then
     89 		for d in $(find $HOME/dev/git -type d -name mirrors -prune -o -type d -name .git -print); do
     90 			r=$(basename $(dirname $d))
     91 			if [ $1 = $r ]; then
     92 				cd $d
     93 			fi
     94 		done
     95 	fi
     96 }
     97 
     98 qr() {
     99 	curl qrenco.de/$1
    100 }
    101 
    102 rnd() {
    103 	cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
    104 }
    105 
    106 backup() {
    107 	DATA="dev dl doc media .gnupg .ssh .bogoya"
    108 	DEST=backup/main
    109 	for d in $DATA; do
    110 		rsync -avzh --progress --delete $HOME/$d blackbox:$DEST
    111 	done
    112 }
    113 
    114 # Legacy comand for setting terminal titles in tabbed, might play with this ANSI escape later...
    115 #title() {
    116 #	echo -ne "\033]0;$1\007"
    117 #}