configs  Check-in [3041a12b6a]

Overview
Comment:zshrc: Clean up a little
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3041a12b6ac6af77cd91b3b3c24ce5815a4f0f8ef028a3891b3349104e336914
User & Date: js on 2020-08-30 18:25:16
Other Links: manifest | tags
Context
2020-08-31
20:22
Only set up Fossil checkin signing when key exists check-in: 33d4e74312 user: js tags: trunk
2020-08-30
18:25
zshrc: Clean up a little check-in: 3041a12b6a user: js tags: trunk
12:03
setup.sh: Clean up a little check-in: bfbe9e5b51 user: js tags: trunk
Changes

Modified zshrc from [790f05f245] to [ca9590b539].

55
56
57
58
59
60
61






62


63




64
65
66
67
68
69
70

autoload -U compinit
compinit -C

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







__find_command() {


	which "$1" &>/dev/null && echo "$1" || echo "$2"




}

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







>
>
>
>
>
>

>
>
|
>
>
>
>







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
			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
	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

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"









if which fossil &>/dev/null; then

	alias fl="fossil"
	alias flc="fossil changes --differ"

	fld() {
		if which colordiff &>/dev/null; then
			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 $?







|
|













|

>
>
>
>
>
>
>
>
|
>




<
|
<
<
<
<
<
<
<







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

__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
}

__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 __has_command fossil; then
	alias fl="fossil"
	alias flc="fossil changes --differ"

	fld() {

		fossil diff -N "$@" | colordiff | less -FRX







	}

	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
			$=importmarks_fossil |
		LC_ALL=C git fast-import			\
			--export-marks=$gitdir/git.marks	\
			$=importmarks_git
	}
fi

if which cvs &>/dev/null; then
	cvsd() {
		if which colordiff &>/dev/null; then
			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

which pkg_chk &>/dev/null && alias pkg_chk="MAKEFLAGS= pkg_chk"
which pkg_rolling-replace &>/dev/null &&
	alias pkg_rolling-replace="MAKEFLAGS= pkg_rolling-replace"

which url2pkg &>/dev/null && alias url2pkg="MAKEFLAGS= url2pkg"

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


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"



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

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


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

cross() {
	if [ $# = 0 ]; then
		echo 'Usage: cross platform [architecture1] [architecture2]' \







|

<
|
<
<
<
<
<
<
<




>
|
|

>
|


|

>
|
|
|
>

>
|
|
|
|
|
|
|
|
|
|

|
|
|
|
>







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 __has_command cvs; then
	cvsd() {

		cvs diff -uN "$@" | colordiff | less -FRX







	}
fi

# pkgsrc does not like MAKEFLAGS including -j
__has_command pkg_chk &&
	alias pkg_chk="MAKEFLAGS= pkg_chk"
__has_command pkg_rolling-replace &&
	alias pkg_rolling-replace="MAKEFLAGS= pkg_rolling-replace"
__has_command url2pkg &&
	alias url2pkg="MAKEFLAGS= url2pkg"

# mpv does not like locales that use , as decimal point.
__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"
fi

if __has_command cryptopassphrase; then
	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"
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

			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
				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)







|







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 ! __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)