-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_nova.sh
executable file
·134 lines (121 loc) · 3.7 KB
/
setup_nova.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env bash
###############################################################################
# Script Name : setup_nova.sh
# Description : Link Nova extensions and preferences to
# `~/Library`
# Args : None
# Author : Doug Emery
# Email : [email protected]
#
# See:
#
# https://help.panic.com/nova/moving-data/
#
# Note this method does not handle code clips. For that the doc
# says:
#
# > Clips can be exported to a file from the Clips Sidebar by clicking the
# > gear icon at the bottom and choosing Export Clips… from the menu, and can
# > be imported from a file using the Import Clips… option in the same menu.
###############################################################################
shopt -s expand_aliases
source $(dirname $0)/functions.sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# Nova Extensions
nova_folder="${HOME}/Library/Application Support/Nova/"
extensions="${nova_folder}/Extensions"
extensions_backup=${extensions}.$(tstamp)
source_extensions="${SCRIPT_DIR}/Library/Application Support/Nova/Extensions"
# Nova Preferences
prefs_folder="${HOME}/Library/Preferences"
nova_prefs="${prefs_folder}/com.panic.Nova.plist"
source_prefs="${SCRIPT_DIR}/Library/Preferences/com.panic.Nova.plist"
# quit if Nova isn't installed
if is_installed "Nova.app"
then
msg "Nova is installed; proceeding"
else
error "Please install Nova before running setup"
fi
# quit if Nova is running
if is_running "Nova.app.*/Nova$"
then
error "Refusing to run setup while Nova is running"
fi
# quit if there's no Nova directory in Application Support
if [[ -e "${nova_folder}" ]]
then
msg "Nova support directory found: ${nova_folder}"
else
error "Nova support directory not found: ${nova_folder}"
fi
# link extensions and preferences is needed
timestamp=$(tstamp)
if [[ -L "${extensions}" ]]
then
warning "Already symlinked: ${extensions}"
else
# backup the extensions
if [[ -e "${extensions}" ]]
then
thing_backup="${extensions}.${timestamp}"
msg "Backing up: ${extensions}"
mv "${extensions}" "${thing_backup}" || error "Unable to to backup ${extensions}"
msg "Backed up ${thing_backup}"
fi
##
# link local Nova Extensions dir to Nova support dir
##
msg "Create symlink: ${extensions} ->"
msg " ${source_extensions}"
(
cd "${nova_folder}"
ln -s "${source_extensions}"
)
if ls -l "${extensions}" >/dev/null
then
msg "Nova Extensions are now available"
else
error "Something went wrong; Nova Extensions not installed"
fi
fi
##
# Install the python language server stuff
##
# make sure homebrew bin directory is the first in the path
msg "Installing the python-language-server"
pip3 install 'python-language-server[all]'
packages="pyls-mypy pyls-isort pyls-black"
pip3 install ${packages}
msg "SUCCESS! Python language server installed"
msg
msg "Add the following to Nova.app Python extension prefs:"
msg
msg " $(which python3)"
msg " $(which pyls)"
msg
## We can't symlink preferences. Nova writes prefs directly
# the file and overwrites in symlinks.
#
# Just check to see which is newer.
if [[ ${nova_prefs} -nt ${source_prefs} ]]
then
warning "Nova preferences are out of sync:"
warning "${nova_prefs}"
warning " is newer than: ${source_prefs}"
msg "To update this repo's version run:"
cat << EOF
cp ${nova_prefs} ${source_prefs}
cd ${HOME}/.dotfiles
git add ${source_prefs}
git commit -m "Udating Nova prefs"
EOF
else
warning "Nova preferences are out of sync:"
warning "${source_prefs}"
warning " is new than: ${source_prefs}"
msg "Run the following to update your Nova preferences"
cat <<EOF
cp ${source_prefs} ${nova_prefs}
EOF
fi