updater.sh add open file function

This commit is contained in:
overdodactyl 2018-11-24 11:12:08 -07:00
parent 76ca015352
commit 3b70fab06d

View file

@ -141,6 +141,16 @@ download_file () {
$dlcmd "${url}" &>/dev/null && echo "$tf" || echo "" # return the temp-filename (or empty string on error)
}
open_file () { #expects one argument: file_path
if [ "$(uname)" == "Darwin" ]; then
open "$1"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
xdg-open "$1"
else
echo -e ${RED}"Error: Sorry, opening files is not supported for your OS."${NC}
fi
}
show_banner () {
echo -e
@ -298,7 +308,7 @@ update_userjs () {
fi
if [ "$VIEW" = true ]; then
open user.js
open_file "${PWD}/user.js"
fi
}
@ -358,7 +368,7 @@ if [ $# != 0 ]; then
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
mv $tfile "${tfile}.js"
echo -e ${ORANGE}"Warning: user.js was saved to temporary file ${tfile}.js"${NC}
open "${tfile}.js"
open_file "${tfile}.js"
exit 1
;;
\?)