-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.sh
48 lines (37 loc) · 861 Bytes
/
lib.sh
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
#!/usr/bin/env bash
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
function ok() {
echo -e "${COL_GREEN}[ok]:${COL_RESET} $1"
}
function running() {
echo -e "\n${COL_BLUE}[run]:${COL_RESET} $1"
}
function action() {
echo -e "${COL_YELLOW}[action]:${COL_RESET} $1"
}
function error() {
echo -e "${COL_RED}[error]:${COL_RESET} $1"
}
function symifne() {
SRC=$1
DEST=$2
if [[ -z "$2" ]]; then
DEST=$2
fi
action "Creating symlink from $DEST to $SRC."
read -rp "Continue? [Y/n]: " yn
case $yn in
[Nn]* ) return;;
esac
if [[ -L "$DEST" ]]; then
ok "Symlink destination already exists."
return
fi
ln -s "$HOME/.dotfiles/$SRC" "$DEST"
ok "Linked $DEST.";
}