void

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

.bash_functions (2615B)

      1 #!/bin/sh
      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 extract() {
     33 	if [ ! -z "$1" ]; then
     34 		if [ -f $1 ]; then
     35 			case $1 in
     36 				*.tar.bz2) tar xvjf $1    ;;
     37 				*.tar.gz)  tar xvzf $1    ;;
     38 				*.tar.xz)  tar xvJf $1    ;;
     39 				*.lzma)    unlzma $1      ;;
     40 				*.bz2)     bunzip2 $1     ;;
     41 				*.rar)     unrar x -ad $1 ;;
     42 				*.gz)      gunzip $1      ;;
     43 				*.tar)     tar xvf $1     ;;
     44 				*.tbz2)    tar xvjf $1    ;;
     45 				*.tgz)     tar xvzf $1    ;;
     46 				*.zip)     unzip $1       ;;
     47 				*.Z)       uncompress $1  ;;
     48 				*.7z)      7z x $1        ;;
     49 				*.xz)      unxz $1        ;;
     50 				*)         echo "$1 - unknown archive format" ;;
     51 			esac
     52 		else
     53 			echo "$1 - file does not exist"
     54 		fi
     55 	fi
     56 }
     57 
     58 flash() {
     59 	sudo dd bs=4M if=$1 of=$2 status=progress
     60 	sudo /bin/sync
     61 }
     62 
     63 gcp() {
     64 	git add . && git commit -S -m "$*" && git push
     65 }
     66 
     67 hf() {
     68 	curl -F file=@$1 https://hardfiles.org/ # yeah thats right motherfucker, real bay shit, for real bay motherfuckers.
     69 }
     70 
     71 mntusb() {
     72 	sudo mount $1 /mnt -o uid=$(id -u),gid=$(id -g)
     73 }
     74 
     75 repo() {
     76 	if [ ! -z "$1" ]; then
     77 		for d in $(find $HOME/dev/git -type d -name mirrors -prune -o -type d -name .git -print); do
     78 			r=$(basename $(dirname $d))
     79 			if [ $1 = $r ]; then
     80 				cd $d
     81 			fi
     82 		done
     83 	fi
     84 }
     85 
     86 qr() {
     87 	curl qrenco.de/$1
     88 }
     89 
     90 rnd() {
     91 	cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
     92 }
     93 
     94 backup() {
     95 	DATA="dev dl doc media .gnupg .ssh .bogoya"
     96 	DEST=backup/main
     97 	for d in $DATA; do
     98 		rsync -avzh --progress --delete $HOME/$d blackbox:$DEST
     99 	done
    100 }
    101 
    102 # Legacy comand for setting terminal titles in tabbed, might play with this ANSI escape later...
    103 #title() {
    104 #	echo -ne "\033]0;$1\007"
    105 #}