#!/linuxSucks/Install tg-telegram TUI

Apr 17, 2021

Requirements

The only requirement for tg to run is

Also you need pip, if is not installed in your system

Archi Linux

sudo pacman -S python-pip

Void Linux

sudo xbps-install -S python3-pip

Arch Linux AUR

Tg is in the AUR repos in arch

yay -S telegram-tg

Install from source

To install tg from source here are the repo and the commands you need to run

git clone https://github.com/paul-nameless/tg.git
cd tg
pip install python-telegram
pip install .
tg

In Void Linux the executable file is installed in /home/user/.local/bin/tg, you need to move the tg file to /usr/local/bin/

sudo cp ~/.local/bin/tg /usr/local/bin

Also we can do a symlink

sudo ln -s ~/.local/bin/tg /usr/local/bin

Configuration

The configuration file for tg is located in /home/user/.config/tg/confi.py

Simple config

# should start with + (plus) and contain country code
PHONE = "[phone number in international format]"

Mailcap file

Mailcap file is used for deciding how to open telegram files (docs, pics, voice notes, etc.). Path to the file can be overriden with MAILCAP_FILE in config file.

Example .mailcap

# media
video/*; mpv "%s"
audio/ogg; mpv --speed 1.33 "%s"
audio/mpeg; mpv --no-video "%s"
image/*; qView "%s"

# text
text/html; w3m "%s"
text/html; open -a Firefox "%s"
text/plain; less "%s"

# fallback to vim
text/*; vim "%s"

Keybindings

Chats

| Key   | Action                          |
| ----- | ------------------------------- |
| j,k   | : move up/down                  |
| J,K   | : move 10 chats up/down         |
| g     | : go to top chat                |
| l     | : open msgs of the chat         |
| m     | : mute/unmute current chat      |
| p     | : pin/unpin current chat        |
| u     | : mark read/unread              |
| r     | : read current chat             |
| c     | : show list of contacts         |
| dd    | : delete chat or remove history |
| ng    | : create new group chat         |
| ns    | : create new secret chat        |
| /     | : search in chats               |
| ?     | : show help                     |

Msgs

| Key          | Actions                                                                    |
| ------------ | -------------------------------------------------------------------------- |
| j,k          | : move up/down                                                             |
| J,K          | : move 10 msgs up/down                                                     |
| G            | : move to the last msg (at the bottom)                                     |
| D            | : download file                                                            |
| l            | : if video, pics or audio then open app specified in mailcap file          |
| e            | : edit current msg                                                         |
| <space>      | : select msg and jump one msg down (use for deletion or forwarding)        |
| <ctrl+space> | : same as space but jumps one msg up                                       |
| y            | : yank (copy) selected msgs with to internal buffer (for forwarding)       |
| p            | : forward (paste) yanked (copied) msgs to current chat                     |
| dd           | : delete msg for everybody (multiple messages will be deleted if selected) |
| i or a       | : insert mode, type new message                                            |
| I or A       | : open vim to write long msg and send                                      |
| v            | : record and send voice message                                            |
| r,R          | : reply to a current msg                                                   |
| sv           | : send video                                                               |
| sa           | : send audio                                                               |
| sp           | : send picture                                                             |
| sd           | : send document                                                            |
| o            | : open url present in message (if multiple urls, urlview will be opened)   |
| ]            | : next chat                                                                |
| [            | : prev chat                                                                |
| u            | : show user info (username, bio, phone, etc.)                              |
| c            | : show chat info (e.g. secret chat encryption key, chat id, state, etc.)   |
| ?            | : show help                                                                |
| !            | : open msg with custom cmd                                                 |

Home  Linux  Notes  Blog Spot