~kota/dots

ref: 0d787967923493aac71744a47368ec7545c2ee24 dots/ksh/.kshrc -rw-r--r-- 2.3 KiB
0d787967Dakota Walsh notabar: add tide 6 months ago
                                                                                
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
# basic settings
export HISTFILE=$HOME/.history
export HISTSIZE=10000
export PS1='\w '
export TERM='xterm-256color'
export EDITOR='/usr/local/bin/nvim'
export VISUAL='/usr/local/bin/nvim'
export PAGER='/usr/bin/less'
export NNN_OPTS='cC'
export PATH=$HOME/bin:$PATH
set -o vi
set -o vi-tabcomplete

## aliases
alias sudo='doas'
alias rsync='rsync -avP'
alias hist='cat .history|less'
alias m='make all'
alias mc='make clean'
alias c='clear'
alias vi='nvim'
alias ls='ls'
alias la='ls -lAh'
alias l='ls -1F'
alias t='tmux'
alias tn='tmux new -s'
alias ta='tmux attach -t'
alias tls='tmux ls'
alias xi='doas pkg_add'
alias xu='doas pkg_add -u'
alias xs='pkg_info -Q'
alias xr='doas pkg_add -aa'
alias xrm='doas pkg_delete'
alias xc='doas pkg_delete -a'
alias xinfo='pkg_info'
alias xlist='pkg_info -m'
alias todo='$EDITOR $HOME/TODO'
alias disks='sysctl hw.disknames'
log() {
	zcat /var/www/logs/access.log.*.gz | cat /var/www/logs/access.log - | grep -v syslog | goaccess --no-global-config
}

## functions
cf() {
	if [ "$PWD" = "$HOME" ]; then
		cd "$(fzf < "$HOME/.cache/search-cache-dirs")" || exit
	else
		cd "$(fd -H --type d | fzf)" || exit
	fi
}
cfh() {
        cd "$(fd -H --type d | fzf)" || exit
}
of() {
	if [ "$PWD" = "$HOME" ]; then
		SELECTION=$(fzf < "$HOME/.cache/search-cache-files")
	else
		SELECTION=$(fd --type f | fzf)
	fi
	xdg-open "$SELECTION" >/dev/null 2>&1 &
}
ofh() {
	SELECTION=$(fd --type f | fzf)
	xdg-open "$SELECTION" >/dev/null 2>&1 &
}
vf() {
        "$EDITOR" "$(fd -H --type f | fzf)"
}
vcf() {
        SELECTION=$(fd -H --type f | fzf)
	cd "$(dirname "$SELECTION")" || exit
	"$EDITOR" "$(basename "$SELECTION")"
}
n () {
	# Block nesting of nnn in subshells
	if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
		echo "nnn is already running"
		return
	fi

	# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
	# To cd on quit only on ^G, remove the "export" as in:
	#     NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
	# NOTE: NNN_TMPFILE is fixed, should not be modified
	export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

	# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
	# stty start undef
	# stty stop undef
	# stty lwrap undef
	# stty lnext undef

	nnn "$@"

	if [ -f "$NNN_TMPFILE" ]; then
		. "$NNN_TMPFILE"
		rm -f "$NNN_TMPFILE" > /dev/null
	fi
}