-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.zsh
55 lines (46 loc) · 1.11 KB
/
functions.zsh
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
# [ -n "${DOTFILES_FUNCTIONS}" ] && return; export readonly DOTFILES_FUNCTIONS=0;
function error () {
( tput setaf 1; echo "ERROR $@"; tput sgr0 ) 1>&2
}
function warning () {
( tput setaf 3; echo "WARNING $@"; tput sgr0 ) 1>&2
}
function info () {
( tput setaf 2; echo -n "INFO "; tput sgr0; echo "$@" ) 1>&2
}
function err_exit () {
error "$@"
exit 1
}
# warning 'dotfiles/functions.zsh is being loaded'
function checkyes () {
local result=1
tput setaf 6
printf "$@ [y/N]: " && read yn
case "$yn" in
[yY]*) local result=0 ;;
[qQ]*) exit 0 ;;
*) local result=1 ;;
esac
tput sgr0
return $result
}
function checkdependency () {
if command -v "$1" >/dev/null 2>&1; then
return 0
else
error "You do not have '$1' installed."
error 'Install it and run this script again'
return 1
fi
}
function followlink () {
if command -v 'readlink' >/dev/null 2>&1; then
eval "readlink $@"
elif command -v 'greadlink' >/dev/null 2>&1; then
eval 'greadlink $@'
else
error "No command to follow link found. Please install readlink(Linux) or greadlink(Mac)"
fi
}
true