-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bef821
commit 842a1a7
Showing
1 changed file
with
4 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
CONF_PATH="${HOME}/.config/Code/User" | ||
if [[ $(uname) == "Darwin" ]]; then | ||
CONF_PATH="${HOME}/Library/Application Support/Code/User/" | ||
fi | ||
mkdir -p "${CONF_PATH}" | ||
|
||
SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
__install_settings_file() { | ||
local cnf_file=$1 | ||
local trg_file=${2:-${cnf_file}} | ||
|
||
local ORIGIN="${SELF_PATH}/${cnf_file}" | ||
local TARGET="${CONF_PATH}/${trg_file}" | ||
|
||
# if file exists, backup. | ||
[[ -f ${TARGET} ]] && [[ ! -L ${TARGET} ]] && mv "${TARGET}"{,.backup} | ||
|
||
# if link already exists, return. | ||
[[ -L ${TARGET} ]] && echo "Link for ${cnf_file} already exists" && return | ||
|
||
# install sym link | ||
echo -e "Linking \e[0;35m${ORIGIN}\e[0m -> \e[0;36m${TARGET}\e[0m" | ||
ln -s "${ORIGIN}" "${TARGET}" | ||
} | ||
lnx "${SRC}/settings.json" "${CONF_PATH}/settings.json" | ||
|
||
__install_settings_file settings.json | ||
if [[ $(uname) == "Linux" ]]; then | ||
__install_settings_file keybindings.json | ||
lnx "${SRC}/keybindings.json" "${CONF_PATH}/keybindings.json" | ||
fi |