Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gen-nanorc.sh - github.com/serialhex/nano-highlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84b1cc72ec4d21bca93ccc16701af3bf689a86ac (plain)
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