Terminal: Installing and customizing the Kitty terminal emulator on Mac ver. 6

Last Updated on February 19, 2022 by shibatau

The V is added.

I. Installation

This may be the easiest way though you have to install Homebrew beforehand. Run the following command in the terminal.

brew install kitty

You can learn more here:

https://techviewleo.com/setup-kitty-terminal-emulator-on-linux-macos/

II. Change themes

This is also the easiest way of changing colors. Run the following command and select the theme that you like with the arrow keys.

kitty +kitten themes

You can learn more here:

Changing kitty colors

III. Layouts

There are many different layouts available. You can switch layouts using ctrl + shift + l. To control which layouts are available use enabled_layouts.

You can learn more here:

Arrange windows

IV. Display an image in the terminal

You can display an image with the following code:

kitty +kitten icat NAME.jpg

You can also control how the image appears in the terminal with Python scripts. Here is the minimal Python codes. Save the file as png.py anywhere you like.

import sys
from base64 import standard_b64encode

def serialize_gr_command(**cmd):
    payload = cmd.pop('payload', None)
    cmd = ','.join(f'{k}={v}' for k, v in cmd.items())
    ans = []
    w = ans.append
    w(b'\033_G'), w(cmd.encode('ascii'))
    if payload:
        w(b';')
        w(payload)
    w(b'\033\\')
    return b''.join(ans)

def write_chunked(**cmd):
    data = standard_b64encode(cmd.pop('data'))
    while data:
        chunk, data = data[:4096], data[4096:]
        m = 1 if data else 0
        sys.stdout.buffer.write(serialize_gr_command(payload=chunk, m=m, **cmd))
        sys.stdout.flush()
        cmd.clear()

with open(sys.argv[-1], 'rb') as f:
    write_chunked(a='T', f=100, data=f.read())

You can learn more here:

Terminal graphics protocol

Now I have saved the above scripts in the home directory. I’m working in the Desktop directory, then I can display NAME.png in the directory with the following scripts.

python ~/Pictures/png.py NAME.png

Here is the image shown:

V. Commands and Shortcuts

Tab

Ctrl + shift + t Open a new tab

Ctrl + shift + q Close a tab

Ctrl + shift + right arrow Move to the right tab

Previous tab: ctrl + shift + left arrow Move to the left tab

Window

Ctrl + shift + enter Open a new window

Ctrl + shift + w Close a window

Ctrl + shift + ] Move to the next window

Ctrl + shift + [ Move to the previous window

Copy to clipboard

kitty +kitten clipboard

Ex. ls | kitty +kitten clipboard

See more:

Kitty-Overview

Not completed yet.

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.