Repository navigation
Expand file tree
/
Copy pathlib.sh
More file actions
96 lines (83 loc) · 1.9 KB
/
Copy pathlib.sh
File metadata and controls
96 lines (83 loc) · 1.9 KB
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
#!/bin/bash
source bash_terminal_colours.sh
# some bits borrowed from https://github.com/atomantic/dotfiles/
function ok() {
echo -e "$COL_GREEN[ok]$COL_RESET "$1
}
function bot() {
echo -e "\n$COL_GREEN\[._.]/$COL_RESET - "$1
}
function running() {
echo -en "$COL_YELLOW ⇒ $COL_RESET"$1": "
}
function action() {
echo -e "\n$COL_YELLOW[action]:$COL_RESET\n ⇒ $1..."
}
function warn() {
echo -e "$COL_YELLOW[warning]$COL_RESET "$1
}
function error() {
echo -e "$COL_RED[error]$COL_RESET "$1
}
function is_osx(){
PLATFORM="$(uname -s)"
if [ "$PLATFORM" = "Darwin" ]; then
return 0
else
return 1
fi
}
function get_confirmation() {
#have something here to allow for a yes/no dialog
#TODO: finish this tonight
read -p $1 -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "yes"
return 0
else
echo "no"
return 1
fi
}
# expects 2 arguments
# $1 - file (with path) you're "archiving" and overwriting
# $2 - file (with path) that is the source of the symlink
function move_and_symlink() {
if [ -f ${1} ]; then
mv ${1} ${1}-old
fi
#TODO: allow for option between -Fs and -s so gitconfig file will work
ln -Fs ${2} ${1}
}
# expects 3 arguements
# $1 - function being called
# $2 - success message
# $3 - error message
function is_success() {
if [[ $1 -eq 0 ]]; then #TODO: why is this wrapped twice?
ok "$2"
else
warn "$3"
fi
}
# expects 4 args
# $1 path to bundle dir
# $2 bundle repo name
# $3 bundle repo url
function get_vim_bundle() {
#pull out bundle name from bundle repo url
FILE_NAME=${3##*/}
BUNDLE_NAME=`echo "$FILE_NAME" | cut -f 1 -d '.'`
if [ -d ${1}/${BUNDLE_NAME} ]; then
ok "${BUNDLE_NAME} already installed"
else
running "${2} not installed. Installing now"
pushd $1
git clone ${3}
SUCCESS=$?
is_success $SUCCESS "installed ${BUNDLE_NAME}" "error downloading ${BUNDLE_NAME}"
popd
fi
}