code / scripts

Lines748 Shell528 Python72 Lua67 Bourne Again Shell62 make15
1 others 4
Markdown4
(57 lines)
1 #!/bin/sh
2 # A bunch of miscellaneous tasks I often forget the commands for.
3 set -e
4 source ~/.profile
6 case "$@" in
7 turn\ wifi\ on|turn\ the\ wifi\ on|wifi\ on)
8 nmcli radio wifi on;;
9 turn\ wifi\ off|turn\ the\ wifi\ off|wifi\ off)
10 nmcli radio wifi off;;
11 toggle\ wifi|refresh\ wifi|reload\ wifi\|wifi\ toggle)
12 echo "Toggling wifi off and on again..."
13 nmcli radio wifi off
14 sleep 1
15 nmcli radio wifi on
16 ;;
17 connect\ to\ wifi|wifi)
18 nmtui;;
19 bright)
20 xbacklight -set "30";;
21 dim\ the\ screen|dim\ screen|dim)
22 xbacklight -set "0.1";;
23 screen\ off|turn\ screen\ off|turn\ the\ screen\ off)
24 xbacklight -set "0";;
25 mute)
26 amixer set Master off;;
27 unmute)
28 amixer set Master on;;
29 sync)
30 src="$(ask -p "Which dir? ")"
31 dest="$(ask -p "To where? " -q "$src")"
32 if ! expr "$src" : ".*/$"; then src="$src/"; fi
33 rsync -ahzt --partial --info=progress2 bruce@"$CLUNKER_IP":"$src" "$dest";;
34 mount\ desktop|mount\ clunker)
35 sshfs bruce@"$CLUNKER_IP":/ ~/clunker -o reconnect;;
36 unmount\ clunker)
37 umount ~/clunker;;
38 sleep\ clunker|hibernate\ clunker)
39 ssh -t bruce@"$CLUNKER_IP" 'systemctl hibernate';;
40 mount\ website|website)
41 sshfs bphill@bruce-hill.com:/home/bphill ~/bruce-hill.com -o reconnect;;
42 unmount\ website)
43 umount ~/bruce-hill.com;;
44 mount\ usb)
45 sudo mount /dev/sda1 /mnt;;
46 unmount\ usb|remove\ usb)
47 sudo umount /mnt;;
48 hdmi)
49 xrandr --output DP3 --mode auto --primary;;
50 update\ clock|update\ time)
51 sudo ntpd -gq;;
52 uh)
53 nvim ~/scripts/uh;;
54 *)
55 printf "Not a recognized \033[1muh\033[0m command:\033[31;1m %s\033[0m\n" "$@"
56 exit 1;
57 esac