-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit-config
More file actions
executable file
·43 lines (34 loc) · 1.04 KB
/
edit-config
File metadata and controls
executable file
·43 lines (34 loc) · 1.04 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
#!/usr/bin/env bash
# Open config file in NeoVim
set -o pipefail
SCRIPT_DIR="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)"
source "${SCRIPT_DIR}/bash_modules/terminal.sh"
source "${SCRIPT_DIR}/bash_modules/config.sh"
function print_usage() {
cat <<EOF
Usage: $(basename "$0") [key] [value]
Edit the config configuration file in NeoVim
Optional arguments:
key The config key to add/update before editing
value The config value to set for the key (defaults to empty string)
-h, --help Show this help message and exit
EOF
}
if [[ $# -gt 2 || "${1}" == "-h" || "${1}" == "--help" ]]; then
print_usage
exit 1
fi
log_title "Edit Config Configuration"
if ! command -v nvim >/dev/null; then
log_error "ERROR: NeoVim (nvim) is not installed or not in PATH"
exit 1
fi
if [[ $# -ge 1 ]]; then
key="${1}"
value="${2:-}"
log_message "Setting '${key}' = '${value}'"
config_set "${key}" "${value}"
fi
config_file="$(config_get_path)"
log_message "Opening config file: '${config_file}'"
nvim "${config_file}"