aboutsummaryrefslogtreecommitdiffstats
path: root/.zshrc-linux
blob: 16d4add35ed8db502d30f25042d83e35bf2df433 (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
################### ALIASES ##################
alias ag='ag --color-match "1;34"'
alias diff='colordiff'
alias grep='grep --color=auto'
alias latex='latex -output-format=pdf'
alias less='less -R'
alias ls='ls --color=auto'
alias ll='ls -lh --color=auto'

alias :q='exit'

export EDITOR="vim"
export PAGER="less -R"

################## FUNCTIONS ##################

# bits to human readable value
b2h() {
	local suffixes=( 'B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y' )
	local sindex=1
	local val=$1
	[[ -z $(echo $1 | grep "^[0-9]*$") ]] && read val
	
	while [[ $(echo $val / 1024 | bc) -ne 0 ]]; do
		val=$(echo "scale=2; $val / 1024" | bc)
		let sindex=sindex+1
	done
	
	echo "${val}${suffixes[$sindex]}"
}

if [[ $(whence fzf) ]]; then
	f() {
		local file
		fzf --color=16 --black \
			--bind=ctrl-b:page-up,ctrl-f:page-down \
			| read file

		[[ -z "$file" ]] && return

		[[ $(xclip -o 2>/dev/null) ]] || { echo "${file:a}"; return }

		echo "${file:a}" | xclip -i -selection clipboard
	}
fi

# ignore non-tracked files
git() {
	if [[ $# -gt 0 ]] && [[ "$1" == "status" ]]; then
		shift
		$(which -p git) status -uno "$@"
	else
		$(which -p git) "$@"
	fi
}