summary refs log tree commit diff
path: root/okshrc
blob: 2e0b38222714f60b80cd60153dd150d01b31d0da (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
# for st and uemacs
stty -ixon

# history
export HISTFILE="$HOME/.history"
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTCONTROL=ignoredups:ignorespace

# de/wm
export DESKTOP_SESSION="sowm"

# terminal
export GPG_TTY=$(tty)
export COLORTERM=truecolor

# gpg
export GPG_KEY=""

# deepseek
export DEEPSEEK_API_KEY=""

# paths
export PATH="/usr/lib/ccache/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"

# ccache
export CCACHE_MAXSIZE="20G"
export CCACHE_COMPRESS="1"
export CCACHE_COMPRESSLEVEL="1"
export CCACHE_SLOPPINESS="time_macros,include_file_time,include_file_ctime,file_macro"
export CCACHE_BASEDIR="$HOME"

# editors, pagers, aliases, funcs
export EDITOR="mg"
export VISUAL="mg"
export PAGER="less"
export MANPAGER="less -R"

alias german='export LANG=de_DE.UTF-8 LC_ALL=de_DE.UTF-8'
alias english='export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8'
alias timestamp='date +%Y-%m-%d_%H-%M -u'
alias filehash='openssl dgst -shake256 -xoflen 128'
alias rconnect='rtl_fm -f 467.7125M -M fm -s 22050 -g 40 -l 50 | aplay -r 22050 -f S16_LE'
alias ls='ls -p'

gpgsign() {
	if [ $# -eq 0 ]; then
		echo "err: bad usage."
		return 2
	fi

	local binary_mode=0
	local file=""

	while [ $# -gt 0 ]; do
		case "$1" in
			-b)
				binary_mode=1
				shift
				;;
			-*)
				echo "err: not a option '$1'."
				return 2
				;;
			*)
				file="$1"
				shift
				;;
		esac
	done

	if [ -z "$file" ]; then
		echo "err: no filename specified."
		return 1
	fi

	local backup_file="${file}.bak.$$"
	cp "$file" "$backup_file" || return 1

	local temp_file=$(mktemp -p /tmp gpgsign.XXXXXX) || {
		rm -f "$backup_file"
		return 1
	}

	trap "rm -f '$temp_file' '$backup_file'" EXIT INT TERM

	local sign_cmd="gpg --batch --yes --clearsign"
	[ $binary_mode -eq 1 ] && sign_cmd="gpg --batch --yes --sign"
	
	echo "signing file..."
	$sign_cmd -u "$GPG_KEY" -o "$temp_file" "$file" 2>/dev/null || {
		echo "err: failed to sign."
		mv "$backup_file" "$file"
		rm -f "$temp_file"
		return 1
	}

	if gpg --verify "$temp_file" 2>/dev/null; then
		mv "$temp_file" "$file" && rm -f "$backup_file"
		echo "ok: signed successfully."
		trap - EXIT INT TERM
		return 0
	else
		echo "err: verification failed"
		mv "$backup_file" "$file"
		rm -f "$temp_file"
		return 1
	fi
}

# ps1
# export PS1='[${PWD}]\n> ' this is fancy
export PS1="> "

# dircolors eval
if command -v dircolors >/dev/null 2>&1; then
	eval "$(dircolors -b)"
fi