这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/termux.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,23 @@ values.
As Termux does not support locales, changing this variable is not
recommended and may have unexpected effects.

TOOLS
=====

Tools bundled with termux-tools

`termux-logout`
: Run cleanup commands when executed from last remaining Termux session. Intended to be run from

~/.bash_logout
termux-logout

`termux-title`
: Update Termux tab titles similar to tmux. Run with termux-services package from

$SVDIR/title/run
exec termux-title

FILES
=====

Expand Down
6 changes: 3 additions & 3 deletions scripts/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

# shell scripts:
bin_SCRIPTS = chsh dalvikvm login pkg su termux-backup \
termux-change-repo termux-fix-shebang termux-info termux-open \
termux-change-repo termux-fix-shebang termux-info termux-logout termux-open \
termux-open-url termux-reload-settings termux-reset termux-restore \
termux-setup-package-manager termux-setup-storage termux-wake-lock \
termux-wake-unlock
termux-setup-package-manager termux-setup-storage termux-title termux-wake-lock \
termux-wake-unlock wall

# wrappers around tools in /system/bin:
bin_SCRIPTS += df getprop logcat ping ping6 pm settings top
Expand Down
22 changes: 22 additions & 0 deletions scripts/termux-logout.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# todo source from @TERMUX_PREFIX@/bin/logout
# help
if [ -n "$1" ]; then
echo run this file from \~/.bash_logout to perform exit cleanup from last session
exit 0
fi

pp=$(pidof com.termux)
pids=$(ps --ppid $pp -o pid=)
s=$(echo $pids|wc|tr -s " "|cut -f3 -d" ")
# exit silently if not final session
if [ $s -ne 1 ]; then exit 0; fi

echo leaving final active session running cleanup
service-daemon stop
termux-api-stop

# place custom commands here
# start-stop-daemon --stop --pidfile $HOME/earlyoom.pid --remove-pidfile -v

read -p "press enter to exit"
36 changes: 36 additions & 0 deletions scripts/termux-title.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# help
if [ -n "$1" ]; then
echo run this file from \$SVDIR/title/run to update session titles
exit
fi

# enable logging
# exec >>$HOME/title
exec >/dev/null

pp=$(pidof com.termux)

function titles(){
date
for p in $(ps --ppid $pp -o pid=); do
cp=$(ps --ppid $p -o pid=|head -1)
tty=$(ps -p $p -o tty=|cut -f2 -d/)
if [ -n "$cp" ]; then
cmd=$(ps -p $cp -o cmd=|sed s,:,,|sed s,$HOME,~,)
fi
wd=$(pwdx $p|cut -f2 -d" "|sed s,$HOME,~,)
echo $tty $cp $wd $cmd
if [[ -n "$cp" ]]; then
echo -ne "\e]0;$cmd\a" > /dev/pts/$tty
else
echo -ne "\e]0;$wd\a" > /dev/pts/$tty
fi
done
}

while(true); do
titles
sleep 10
done
23 changes: 23 additions & 0 deletions scripts/wall.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
function show_usage() {
echo usage: "wall <message>"
echo broadcast message to running sessions
exit 0
}

if [ $# -lt 1 ]; then
echo no message given
show_usage
exit 1
fi

case "$1" in
-\?|-h|--help|--usage)
show_usage;;
esac

pp=$(pidof com.termux)
for p in $(ps --ppid $pp -o pid=); do
tty=$(ps -p $p -o tty=|cut -f2 -d/)
echo $@ > /dev/pts/$tty
done