summaryrefslogtreecommitdiff
path: root/.zshrc
blob: af8d7b377f9982cc0cf42b7f99ed44b49ec01d1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
export ZSH="/home/fkfd/.oh-my-zsh"

ZSH_THEME="fkfd"

plugins=(
	git
	python
	pj
	urltools
	mosh
)

source $ZSH/oh-my-zsh.sh

export EDITOR=/usr/bin/nvim
export BROWSER=/usr/bin/firefox
export PROJECT_PATHS=(~/Projects/ ~/Projects/_cloned/ ~/Projects/_archive/)
export PATH="$HOME/.local/bin:$HOME/.local/texlive/2024/bin/x86_64-linux:$PATH"

# utilities
mc () {
	mkdir $1 && cd $1
}

# look at anything
k () {
	if [[ -d $1 ]]; then
		ls $1
	elif [[ -f $1 ]]; then
		$EDITOR $1
	fi
}

share () {
	src=$1
	if [[ $2 == '' ]]; then
		dst=$(basename $1)
	else
		dst=$2
	fi
	scp -r $src www@fkfd.me:www/static/$dst
	echo "https://fkfd.me/static/$(urlencode $dst)"
}

# make aliases accessible in sudo
alias sudo="sudo "

alias incognito="unset HISTFILE"
alias proxy="export SOCKS5_PROXY=127.0.0.1:1080; export HTTP_PROXY=http://127.0.0.1:1081; export HTTPS_PROXY=http://127.0.0.1:1081"

# SSH
alias mrf="mosh root@fkfd.me"
alias mff="mosh fred@fkfd.me"
alias tilde="mosh fkfd@tilde.town -ssh='ssh -i ~/.ssh/id_rsa'"

# file privileges
alias gimme="sudo chown -R $USER ./ && sudo chmod -R +rw ./*"
alias lemme="sudo chmod +x"

# embedded
alias espenv="source ~/p/esp/esp-idf/export.sh"
alias mmu="make && make upload"

# python
alias py="python"
alias venv="source ./venv/bin/activate"

# tools
alias ytdlp="yt-dlp --proxy socks5://localhost:1080/"
alias v="nvim"
alias c="cat"
alias ls="eza"
PRINTER="hpaio:/usb/HP_LaserJet_Professional_M1219nf_MFP?serial=000000000QJA9XJFPR1a"
alias scan="scanimage -d '$PRINTER' --source Flatbed --format=jpeg"
alias scanto="scanimage -d '$PRINTER' --source Flatbed --format=jpeg --mode=Gray --resolution=200 -x 210 -y 297 -o "

alias catpic="montage -tile 1x -geometry +0+0"

alias prc="perf record -F 1000 --call-graph=dwarf -e cycles:u"
alias prp="perf report"

# fun
alias rickroll="vlc -f '~/Videos/Rick Astley - Never Gonna Give You Up (Official Music Video).mkv'"

alias neofetch="if [[ $TERM == 'xterm-kitty' ]]; then neofetch --kitty ~/Pictures/branding/logos/arch.png --size 420px; else neofetch; fi"

# disable beep in x11
set -B 0

# something fucked up
alias je="journalctl -e -f"
alias what-the-fuck-just-happened="journalctl -e -b -1"
alias accel="killall kglobalaccel5 && kglobalaccel5&"

# TA work
alias gccc="gcc -pedantic -std=c11 -Wall -Wextra -Werror -Wno-unused-result -Wconversion -Wvla"

# SJTU VPN
vpn () {
	if ! systemctl is-active --quiet strongswan; then
		sudo systemctl start strongswan
	fi
	if [[ $1 == "on" ]]; then
		sudo swanctl -i --child vpn-student
	elif [[ $1 == "off" ]]; then
		sudo swanctl -t --ike vpn-student
	else
		echo "Usage: $0 [on|off]"
	fi
}

# kdesrc-build #################################################################

## Add kdesrc-build to PATH
export PATH="/home/fkfd/kde/src/kdesrc-build:$PATH"

## Autocomplete for kdesrc-run
function _comp_kdesrc_run {
	local cur
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"

	# Complete only the first argument
	if [[ $COMP_CWORD != 1 ]]; then
		return 0
	fi

	# Retrieve build modules through kdesrc-run
	# If the exit status indicates failure, set the wordlist empty to avoid
	# unrelated messages.
	local modules
	if ! modules=$(kdesrc-run --list-installed);
	then
		modules=""
	fi

	# Return completions that match the current word
	COMPREPLY=( $(compgen -W "${modules}" -- "$cur") )

	return 0
}

## Register autocomplete function
complete -o nospace -F _comp_kdesrc_run kdesrc-run
################################################################################