Spawning a TTY Shell
The first thing to do is use
python3 -c 'import pty;pty.spawn("/bin/bash")'
, which uses Python to spawn a better-featured bash shell. At this point, our shell will look a bit prettier, but we still wonβt be able to use tab autocomplete or the arrow keys, and Ctrl + C will still kill the shell.Step two is:
export TERM=xterm
β this will give us access to term commands such asclear
.Finally (and most importantly) we will background the shell using
Ctrl + Z
. Back in our own terminal we usestty raw -echo; fg
. This does two things: first, it turns off our own terminal echo (which gives us access to tab autocompletes, the arrow keys, andCtrl + C
to kill processes). It then foregrounds the shell, thus completing the process.
Last updated