mirror of
https://github.com/arkenfox/user.js.git
synced 2025-05-16 05:37:11 +02:00
updater.sh add open file function
This commit is contained in:
parent
76ca015352
commit
3b70fab06d
1 changed files with 20 additions and 10 deletions
14
updater.sh
14
updater.sh
|
@ -141,6 +141,16 @@ download_file () {
|
||||||
$dlcmd "${url}" &>/dev/null && echo "$tf" || echo "" # return the temp-filename (or empty string on error)
|
$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 () {
|
show_banner () {
|
||||||
echo -e
|
echo -e
|
||||||
|
@ -298,7 +308,7 @@ update_userjs () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$VIEW" = true ]; then
|
if [ "$VIEW" = true ]; then
|
||||||
open user.js
|
open_file "${PWD}/user.js"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -358,7 +368,7 @@ if [ $# != 0 ]; then
|
||||||
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||||
mv $tfile "${tfile}.js"
|
mv $tfile "${tfile}.js"
|
||||||
echo -e ${ORANGE}"Warning: user.js was saved to temporary file ${tfile}.js"${NC}
|
echo -e ${ORANGE}"Warning: user.js was saved to temporary file ${tfile}.js"${NC}
|
||||||
open "${tfile}.js"
|
open_file "${tfile}.js"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
\?)
|
\?)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue