configs  Diff

Differences From Artifact [790f05f245]:

To Artifact [ca9590b539]:


55
56
57
58
59
60
61






62


63





64
65
66
67
68
69
70
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







+
+
+
+
+
+

+
+
-
+
+
+
+
+








autoload -U compinit
compinit -C

# Ignore case on completion
zstyle ':completion:*' matcher-list 'm:{A-Z}={a-z} m:{a-z}={A-Z}'

__has_command() {
	for i in $@; do
		which $i &>/dev/null && return 0
	done
	return 1
}
__find_command() {
	for i in $@; do
		if __has_command $i; then
	which "$1" &>/dev/null && echo "$1" || echo "$2"
			echo $i
			return 0
		fi
	done
	return 1
}

if [ -n "$grep" -o -n "$grep_color" ]; then
	: ${grep:=$(__find_command ggrep grep)}
	[ -n "$grep_color" -a "$grep_color[1]" != - ] &&
		grep_color="--color=$grep_color"
	if echo x | $grep $grep_color x &>/dev/null; then
194
195
196
197
198
199
200
201
202


203
204
205
206
207
208
209
210
211
212
213
214
215
216

217








218


219
220
221
222
223
224

225
226
227
228
229
230
231
232
233
234
235
236
237
238
206
207
208
209
210
211
212


213
214
215
216
217
218
219
220
221
222
223
224
225
226
227

228
229
230
231
232
233
234
235
236
237

238
239
240
241
242
243


244







245
246
247
248
249
250
251







-
-
+
+













-
+

+
+
+
+
+
+
+
+
-
+
+




-
-
+
-
-
-
-
-
-
-







	done
}
for ext in 7z lha tar tbz tbz2 tar.bz2 tgz tar.gz txz tar.xz rar zip bz2 gz xz
do
	alias -s "$ext=extr"
done

[ "$EDITOR" = vim ] && alias vi=vim
which gpg2 &>/dev/null && alias gpg=gpg2
__has_command vim && alias vi=vim
__has_command gpg2 && alias gpg=gpg2

make() {
	case "$PWD" in
		# pkgsrc needs bmake and does not like MAKEFLAGS including -j.
		*/pkgsrc*)
			MAKEFLAGS= =$(__find_command bmake make) $@
			;;
		*)
			=make $@
			;;
	esac
}

alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
__has_command tmux && alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"

if ! __has_command colordiff; then
	colordiff() {
		red="$(tput setaf 1)"
		green="$(tput setaf 2)"
		reset="$(tput sgr0)"
		sed "s/^+.*$/$green&$reset/" | sed "s/^-.*$/$red&$reset/"
	}
fi
if which fossil &>/dev/null; then

if __has_command fossil; then
	alias fl="fossil"
	alias flc="fossil changes --differ"

	fld() {
		if which colordiff &>/dev/null; then
			fossil diff -N "$@" | colordiff | less -FRX
		fossil diff -N "$@" | colordiff | less -FRX
		else
			red="$(tput setaf 1)"
			green="$(tput setaf 2)"
			reset="$(tput sgr0)"
			fossil diff -N "$@" | sed "s/^+.*$/$green&$reset/" |
				sed "s/^-.*$/$red&$reset/" | less -FRX
		fi
	}

	flgrep() {
		local ret=1
		fossil changes --all . | sed 's/^.*  //' | while read file; do
			grep -H "$@" "$file" && ret=0
			[ $? -gt 1 ] && return $?
295
296
297
298
299
300
301
302

303
304
305

306
307
308
309
310
311
312
313
314
315
316

317
318


319

320

321
322
323

324

325
326
327




328

329
330
331
332
333
334
335
336
337
338










339
340
341
342
343





344
345
346
347
348
349
350
308
309
310
311
312
313
314

315
316


317







318
319
320
321
322


323
324
325
326

327
328
329

330
331
332



333
334
335
336
337
338










339
340
341
342
343
344
345
346
347
348
349




350
351
352
353
354
355
356
357
358
359
360
361







-
+

-
-
+
-
-
-
-
-
-
-




+
-
-
+
+

+
-
+


-
+

+
-
-
-
+
+
+
+

+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+

-
-
-
-
+
+
+
+
+







			$=importmarks_fossil |
		LC_ALL=C git fast-import			\
			--export-marks=$gitdir/git.marks	\
			$=importmarks_git
	}
fi

if which cvs &>/dev/null; then
if __has_command cvs; then
	cvsd() {
		if which colordiff &>/dev/null; then
			cvs diff -uN "$@" | colordiff | less -FRX
		cvs diff -uN "$@" | colordiff | less -FRX
		else
			red="$(tput setaf 1)"
			green="$(tput setaf 2)"
			reset="$(tput sgr0)"
			cvs diff -uN "$@" | sed "s/^+.*$/$green&$reset/" |
				sed "s/^-.*$/$red&$reset/" | less -FRX
		fi
	}
fi

# pkgsrc does not like MAKEFLAGS including -j
__has_command pkg_chk &&
which pkg_chk &>/dev/null && alias pkg_chk="MAKEFLAGS= pkg_chk"
which pkg_rolling-replace &>/dev/null &&
	alias pkg_chk="MAKEFLAGS= pkg_chk"
__has_command pkg_rolling-replace &&
	alias pkg_rolling-replace="MAKEFLAGS= pkg_rolling-replace"
__has_command url2pkg &&
which url2pkg &>/dev/null && alias url2pkg="MAKEFLAGS= url2pkg"
	alias url2pkg="MAKEFLAGS= url2pkg"

# mpv does not like locales that use , as decimal point.
alias mpv="LC_ALL=C mpv"
__has_command mpv && alias mpv="LC_ALL=C mpv"

if __has_command gpg gpg2; then
alias gpg-ssh="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh"
alias gpg-ssh-add="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh-add"
alias gpg-sftp="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh sftp"
	alias gpg-ssh="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh"
	alias gpg-ssh-add="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh ssh-add"
	alias gpg-sftp="SSH_AUTH_SOCK=$GNUPGHOME/S.gpg-agent.ssh sftp"
fi

if __has_command cryptopassphrase; then
pwnk() {
	local clipboard
	if which pbcopy &>/dev/null; then
		clipboard=pbcopy
	elif which xclip &>/dev/null; then
		clipboard=xclip
	else
		echo "No clipboard handler found!"
		return 1
	fi
	pwnk() {
		local clipboard
		if __has_command pbcopy; then
			clipboard=pbcopy
		elif __has_command xclip; then
			clipboard=xclip
		else
			echo "No clipboard handler found!"
			return 1
		fi

	cryptopassphrase $@ | tr -d '\n' | $clipboard
}
alias pw="pwnk -k ~/.cryptopassphrase.key"
alias pws="pwnk -k ~/.cryptopassphrase-server.key"
		cryptopassphrase $@ | tr -d '\n' | $clipboard
	}
	alias pw="pwnk -k ~/.cryptopassphrase.key"
	alias pws="pwnk -k ~/.cryptopassphrase-server.key"
fi

ixio() { curl -F 'f:1=<-' ix.io }
0x0st() { curl -F'file=@-' https://0x0.st }

cross() {
	if [ $# = 0 ]; then
		echo 'Usage: cross platform [architecture1] [architecture2]' \
393
394
395
396
397
398
399
400

401
402
403
404
405
406
407
404
405
406
407
408
409
410

411
412
413
414
415
416
417
418







-
+








			if [ $# != 2 -o -z "$cross_host" ]; then
				echo "Usage: cross amiga m68k|ppc" 1>&2
				return 1
			fi
			;;
		ios | iossim)
			if ! which xcrun &>/dev/null; then
			if ! __has_command xcrun; then
				echo -n "Can only cross-compile for iOS " 1>&2
				echo "on a Mac with Xcode!" 1>&2
				return 1
			fi

			case "$1" in
				ios)