forked from serialhex/nano-highlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-nanorc.sh
36 lines (32 loc) · 1.14 KB
/
gen-nanorc.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
#!/bin/bash
## Generating correct `.nanorc` file.
## You should to set right path starts from $HOME, ends with slash.
## Also it needs blank (or not) ~/.nanorc file
nano_highlight_path="$HOME/nano-highlight/"
nanorc_path="$HOME/"
if [[ ! -e "$nanorc_path".nanorc ]]; then
echo "You don't have .nanorc file."
echo -n "Do you wish to create it in '$nanorc_path' folder? (Y/n) "
read use_home
if echo "$use_home" | grep -iq "^[Nn]"; then
while [[ ! -n "$path" || ! -d "$path" ]]; do
echo -n "Please set the valid path. '$path' is not valid path. "
read path
done
nanorc_path=$path
fi
touch "$nanorc_path".nanorc
echo "'$nanorc_path.nanorc' file created."
fi
if [[ ! -d $nano_highlight_path ]]; then
while [[ ! -n "$folder" || ! -d "$HOME/$folder" ]]; do
echo "'$nano_highlight_path' is not a valid folder."
echo -n "Please set your nano-highlight path. $HOME/"
read folder
done
nano_highlight_path="$HOME/$folder/"
fi
> "$nanorc_path".nanorc
for syntax in $(ls $nano_highlight_path*.nanorc); do
echo "include \"$syntax\"" >> "$nanorc_path".nanorc
done