-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
109 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/data/data/io.neoterm/files/usr/bin/bash | ||
|
||
function file_suffix() { | ||
echo "${1##*.}" | ||
} | ||
|
||
function detect_program() { | ||
case "$1" in | ||
*.tar.* | *.tar ) echo "tar xvf %s" ;; | ||
*.7z ) echo "7za x %s" ;; | ||
*.rar ) echo "unrar x %s" ;; | ||
*.zip ) echo "unzip %s" ;; | ||
* ) echo "" ;; | ||
esac | ||
} | ||
|
||
function do_extract() { | ||
local file="$1" | ||
local dir="$(dirname $file)" | ||
|
||
if [[ ! -f "$file" ]]; then | ||
echo "$file: no such file or directory" | ||
return 1 | ||
fi | ||
|
||
local program="$(detect_program $file)" | ||
|
||
if [[ "$program" == "" ]]; then | ||
echo "Unsupported format: $(file_suffix $file)" | ||
return 1 | ||
fi | ||
|
||
local command="$(printf "$program" "$file")" | ||
|
||
if [[ ! -w "$dir" || ! -r "$file" ]]; then | ||
command="sudo $command" | ||
fi | ||
|
||
cd "$dir" || { | ||
echo "Failed to cd: $dir" | ||
return 1 | ||
} | ||
|
||
eval "$command" | ||
} | ||
|
||
if [[ "$#" == 0 ]]; then | ||
echo "You must specific at least a file to extract." | ||
exit 1 | ||
fi | ||
|
||
clear | ||
while [[ "$#" != 0 ]]; do | ||
file="$1"; shift | ||
echo "[Extracting] $(basename $file)" | ||
do_extract "$file" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/data/data/io.neoterm/files/usr/bin/bash | ||
|
||
set -e | ||
|
||
VIM="$(which vim)" | ||
|
||
if [[ "$VIM"x == ""x ]]; then | ||
echo "Vim is not installed, now installing..." | ||
apt update && apt install -y vim | ||
fi | ||
|
||
$VIM "$@" |
35 changes: 30 additions & 5 deletions
35
app/src/main/java/io/neoterm/component/script/UserScriptComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters