Termux on Chromebook
Last July I bought a Samsung Chromebook Pro for my wife, as she uses google docs/sheets for work and web browser for entertainment – exactly what Chromebook provides. This Chromebook is light-weight (2.4 lbs), thin (0.5”), equipped with touch screen, has about 7 hours battery time for video streaming, and even has a built-in stylus for writing. It is a powerful machine (Intel Core m3 processor, 4G RAM, 32G flash storage), an overkill for just Youtube streaming and web browsing.
(Un)fortunately she was not amused thus the toy is mine. To set up a coding environment, I found a few options at the time:
- wipe out the ChromeOS and install some Linux distro (welcome to the 90s)
- turn on the so-called developer mode (this action voids the warranty and exposes yourself to the risk of accidentally wiping out the hard drive at boot up by pressing the space key) and then
- keep the ChromeOS and
- code with text editors like Caret without compiling/running the code
- code on websites like Cloud9
- ssh to some remote machine (for example, google cloud provides a free f1-micro instance with 30G disc and 0.6G RAM)
I didn’t like any of them and reluctantly opted for the ssh option. It makes the Chromebook useless without fast internet connection.
Fortunately, I discovered an Android app called Termux. It is a Linux terminal emulator that runs on both Android phones and some Chromebooks (see a full list of them here). It enables the following tools in a bash environment without internet connection:
- vim
- git
- latex
- python
- go
- gcc/g++
- make
- tmux
They are basically all I need for coding. It is such a game changer that now I can do real work on this Chromebook. I even find it more preferable than my MacBook Pro since it is easier to carry around and has a battery time of over 10 hours for coding.
To instal termux, you can visit this link:
https://play.google.com/store/apps/details?id=com.termux
There are a few must-have extensions
- Run
termux-setup-storage
: it creates a folder calledstorage
at your home folder which provides access to the Chromebook file systems (downloads, music, pictures, etc) pkg install termux-exec
: for better support for bashpkg install diffutils
: forvimdiff
to workpkg install python-dev
: needed forLDFLAGS=" -lm -lcompiler_rt" pip install numpy
pkg install pkg-config
: somehow this is needed forpip install matplotlib
, otherwise it complains thatfreetype
is not present (although it is)pkg install libffi-dev
: for Jekyllpkg install libxslt-dev libxml2-dev
: for pandas-datareader
For matplotlib
to work properly, you also need to create a config file at
~/.config/matplotlib/matplotlibrc
with the following content:
backend : agg
You may wonder why I bother installing matplotlib
in bash.
With jupyter notebook --ip='0.0.0.0'
, you can see the plots directly in the Chrome browser.
To install scipy, the easiest way is to use the its-pointless repo. All the community repositories can be seen from this link.
To install latex fonts and templates from various publishers, run
tlmgr install collection-publishers
tlmgr install times textcase
Termux also supports multiple sessions (like the old Linux tty1, tty2, etc). The shortcuts are
ctrl+alt+c
: create a new sessionctrl+alt+n
: go to next sessionctrl+alt+p
: go to previous sessionctrl+alt+[1-9]
: go to the numbered session
More of these shortcuts can be found in the termux keyboard page. I notice that by clicking and holding at the left edge of the screen, a drawer is activated to view all the sessions.
For more information in setting things up, check out this blog post by Kenneth White:
In case you want to install a real Linux distro on the Chromebook, checkout this post by Miguel Grinberg
issues
The general complaints I have for this Samsung Chromebook Pro are
- The keyboard sucks: the keys are somewhat small and the layout is too crowded. Although I gradually get used to the layout, now the left ctrl key gets stuck sometimes due to over use. On the other hand the right alt and ctrl keys are almost never used.
- It’s too easy to hit the power button accidentally.
It cannot connect to my company’s VPN.(There is an Android app called VpnCilla that does the trick. It costs $4.99. Also remember to enablechrome://flags/#arc-vpn
)- There is no out-of-box way to display the date in the status bar. One has to move the mouse over the clock to see the date. I don’t know why ChromeOS is like this …
The complaints I have for termux include
Pasting into the vim doesn’t work although pasting into shell works by long press. My current workaround is to either use(Paste isecho <content> >> <file>
or paste into nano.ctrl+alt+v
, works inside vim too, goodbye nano, goodbye long press)- Access to
http://localhost
is not granted. My current workaround is to host web apps at0.0.0.0
and access the termux’s IP100.115.92.2
to test out. - Python multiprocessing module doesn’t work. As a result, flake8 doesn’t work and I have to use (the inferior) pyflakes instead.
epilogue
After six months, I gave up Termux and switched to Crouton and Chromebrew. See my new post here.