Skip to content

Commit

Permalink
Merge pull request #161 from MrCarb0n/scrap
Browse files Browse the repository at this point in the history
prep for external editor app support
  • Loading branch information
VR-25 authored Jul 29, 2022
2 parents 1957a23 + 17fd1c4 commit 3575483
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
19 changes: 17 additions & 2 deletions install/acc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ daemon_ctrl() {


edit() {
ext_app() {
case $1 in
e) ACT=EDIT; print_ext_app e ;;
v) ACT=VIEW; print_ext_app v ;;
esac
sleep 2.5
am start -a android.intent.action.$ACT \
-t 'text/plain' \
-d file://$2 &>/dev/null
}
local file="$1"
shift
if [ -n "${1-}" ]; then
Expand All @@ -105,6 +115,9 @@ edit() {
echo "$@" >> $file
elif [ "$1" = d ]; then
sed -Ei "\#$2#d" $file
elif [ "$1" = app ]; then
shift
ext_app e $file
else
IFS="$(printf ' \t\n')" eval "$* $file"
fi
Expand All @@ -114,8 +127,10 @@ edit() {
*.txt)
if which nano > /dev/null; then
print_quit CTRL-X
else
elif which vim vi > /dev/null; then
print_quit "[esc] :q! [enter]" "[esc] :wq [enter]"
else
print_ext_app e
fi
;;
*.log|*.md|*.help)
Expand All @@ -127,7 +142,7 @@ edit() {
}
case $file in
*.log|*.md|*.help) less $file;;
*) nano -$ $file || vim $file || vi $file;;
*) nano -$ $file || vim $file || vi $file || ext_app e $file ;;
esac 2>/dev/null
fi
}
Expand Down
13 changes: 13 additions & 0 deletions install/strings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ print_not_found() {
echo "$1 not found"
}

print_ext_app() {
case $1 in
e) act=editor ;;
v) act=viewer ;;
esac
cat << EOF
Opening external text $act app choosing
dialog and select any root-compatible
text $act app.
 
e.g., MiXplorer, QuickEdit, etc.
EOF
}

print_help() {
cat << EOF
Expand Down

0 comments on commit 3575483

Please sign in to comment.