Configure and use Termux on Android

Welcome!
I'm sharing here some notes on how i use Termux on my phone. Mainly i use it for two tasks:
Keep up-to-date my git repos for on the go translations and download music without passing via pc.
For those who don't know Termux, it's a fantastic app for Android that you can find in F-Droid. With this app you can transform your phone in a command line terminal.
Let's go!

Setup Termux

Install Termux from F-Droid.
Once installed, at first start it will download the base environment.
Wait few seconds, then let's tweak a bit the UI to make it more comfy.
We will add some commands above the keyboard.

$ pkg install nano
$ mkdir -p ~/.termux/
$ nano ~/.termux/termux.properties
Paste this into nano:
extra-keys = [['ESC','/','-','HOME','UP','END','PGUP'],['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN']]
This line will spawn some useful keys above the keyboard (without the need to switch to other special layouts).
Generic setup is done. Keep reading if you're interested to know the git repo thing or click here for the download music section.

Manage Git Repositories

Setup

Obviously we need to install git.

$ pkg install git
and we should set our username for git:
$ git config --global user.name "NAME"
$ git config --global user.email "USER@EMAIL.TLD"
We're already ready (!) to start! Let's download your forked repository locally. The only thing we need is the URL of your fork, that you can find usually just above the file list of the code, in the top right angle, in github is under the download or copy button, something like https://github.com/silkevicious/Tusky.git
$ git clone [forkURL.git] forkfolder
After some moments, it will download everything into forkfolder (choose the name you want of course). Now, we need to set up a link with the original project. Let's go in the folder that git just created.
$ cd forkfolder
Ok, once you're in we can finally set this link.
Here we need the original git project URL, to keep the same example as before, it will look like https://github.com/tuskyapp/Tusky.git
$ git remote add upstream [originalURL.git]
And, to check if everything is good, run
$ git remote -v
It should show you 2 links for your fork and 2 for your original repo:
origin https://github.com/silkevicious/Tusky.git (fetch)
origin https://github.com/silkevicious/Tusky.git (push)
upstream https://github.com/tuskyapp/Tusky.git (fetch)
upstream https://github.com/tuskyapp/Tusky.git (push)
Ok we finished setup! Now we can finally sync!

Sync

First, we need to see what the original repo committed:

$ git fetch upstream
You should see a list of branch where commits were done. Not every repo has the same name as master branch. For example pleroma has develop, pixelfed has dev.
Check it out carefully!
Anyway, Tusky is an easy repository and has master as name of master branch. Check if you are going to merge the upstream work in the correct branch (in this example we should put master as branch).
$ git checkout [branch]
And now you can merge!
$ git merge upstream/[branch]
Once done, push this syncronization data online with
$ git push
It may ask you your credentials (user/password)
Aaand were done! :-)

Make edits locally

You have corrected a typo here locally and want to push to your repo. Very simple!
After an edit you just have to add a commit message with:

$ git commit -m"yourmessage"
And
$ git push

Update your fork

If you did some edits online instead, you should update your fork locally. It's really simple, you just need:

$ git pull
And you're done!

Download music

Setup

The tool we need to do this is Youtube-DL, but beside this we need to grant termux the access to the storage to save files.

$ pkg install termux-tools
$ termux-setup-storage
Now if you list the directories (with the command ls), you should see a storage folder with all the android subfolders.
Good now let's install youtube-dl and its prerequisites
$ pkg install python
$ pip install youtube-dl
$ pip install --upgrade pip
$ pip install --upgrade youtube-dl
$ pkg install ffmpeg
DONE!

Download

Youtube-DL has plenty of options to do almost anything. Here i'm writing what i use. I usually go to the folder i want to save the file (path may vary from device to device)

$ cd /storage/emulated/0/Music/
Then i launch the command with the URL of the video (it can also be an URL of a playlist)
$ youtube-dl --extract-audio --audio-format vorbis --add-metadata -x URLOFTHEVIDEO
Or if i have multiple video or multiple playlist, i write them all in a file and launch the download with
$ youtube-dl --extract-audio --audio-format vorbis --add-metadata -x -a LIST.TXT
A brief explaination of the parameters i'm using: This is just my choice, but again there are more and more options to use.

PRO TIP

Add aliases to avoid to write everytime all that long string!

$ echo 'alias ytdl="youtube-dl --extract-audio --audio-format vorbis --add-metadata -x"' >> ~/.bashrc;
$ source ~/.bashrc;
So the command would become
$ ytdl URLOFTHEVIDEO

Maintenance

Now and then launch these commands to keep all the programs updated:
$ pkg upgrade
and if you installed youtube-dl also
$ pip install --upgrade pip
$ pip install --upgrade youtube-dl