Skip to content

Commit

Permalink
if $ZAJE_SYNDIR isn't set and ~/.config/zaje/syntax_files doesn't exi…
Browse files Browse the repository at this point in the history
…st, check in

/etc/zaje/syntax_files
  • Loading branch information
jessp01 committed Jul 19, 2023
1 parent 10ad1de commit e191441
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
FMT_ISSUES=$(gofmt -l .)
if test -n "$FMT_ISSUES" ;then printf "gofmt found problems:\n$FMT_ISSUES\n";exit 11; fi
sudo ./install_zaje.sh && ls -al /usr/local/bin/zaje && ls -al /etc/profile.d/zaje.sh && type df && df -h
du -h . | zaje -d -l du
#- name: Test
#run: go test -v
9 changes: 7 additions & 2 deletions install_zaje.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ printf "Downloaded archives are available in ${BLUE}$TMP_DIR${NORMAL}.. Feel fre

if [ "$(id -u)" = 0 ];then
cp ~/bin/${NAME} /usr/local/bin/${NAME}
printf "Copied ${BLUE}~/bin/${NAME}${NORMAL} to ${BLUE}/usr/local/bin/${NAME}${NORMAL}"
printf "Copied ${BLUE}~/bin/${NAME}${NORMAL} to ${BLUE}/usr/local/bin/${NAME}${NORMAL}\n"
# we don't want to override if exists
if [ ! -r /etc/profile.d/zaje.sh ];then
cp "$FUNCTIONS_RC_FILE" /etc/profile.d/zaje.sh
printf "Copied ${BLUE}$FUNCTIONS_RC_FILE${NORMAL} to ${BLUE}/etc/profile.d/${NAME}.sh${NORMAL}"
printf "Copied ${BLUE}$FUNCTIONS_RC_FILE${NORMAL} to ${BLUE}/etc/profile.d/${NAME}.sh${NORMAL}\n"
fi
if [ ! -d /etc/${NAME}/syntax_files ];then
mkdir -p /etc/${NAME}
cp -r "$LEXERS_DIR" "/etc/${NAME}"
printf "Copied ${BLUE}$LEXERS_DIR${NORMAL} to ${BLUE}/etc/${NAME}${NORMAL}\n"
fi
fi

Expand Down
8 changes: 7 additions & 1 deletion zaje.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ func getDefs(filename string, data []byte) []highlight.LineMatch {

if syn_dir == "" {
if syn_dir == "" {
syn_dir = os.Getenv("HOME") + "/.config/zaje/syntax_files"
if stat, err := os.Stat(os.Getenv("HOME") + "/.config/zaje/syntax_files"); err == nil && stat.IsDir() {
syn_dir = os.Getenv("HOME") + "/.config/zaje/syntax_files"
}else{
if stat, err := os.Stat("/etc/zaje/syntax_files"); err == nil && stat.IsDir() {
syn_dir = "/etc/zaje/syntax_files"
}
}
}
}

Expand Down

0 comments on commit e191441

Please sign in to comment.