Install and configure kitty terminal.

Installs the debian package via apt and applies config snippets to the
.config/kitty/kitty.conf
This commit is contained in:
cyteen 2024-04-23 10:00:10 +01:00
parent b2c2d781dd
commit b769ab0328
1 changed files with 708 additions and 0 deletions

708
020_kitty-terminal.sh Normal file
View File

@ -0,0 +1,708 @@
sudo apt install -y kitty fonts-firacode
# https://sw.kovidgoyal.net/kitty/overview/
DEST=${1:-/etc/skel}
KITTY_HOME=${DEST}/.config/kitty
# start the kitty aliases
cat <<-EOF | tee ${DEST}/.zsh_aliases.d/003_kitty.zsh >/dev/null
if test "xterm-kitty" = "xterm-kitty"; then
EOF
# the terminfo used by kitty is not generally available on
# remote machines so we use this alias copy over the terminfo
# and ~/.local/share/kitty-ssh-kitten/
# 5.0K ./shell-integration/zsh/completions
# 23K ./shell-integration/zsh
# 9.0K ./shell-integration/bash
# 9.0K ./shell-integration/fish/vendor_conf.d
# 14K ./shell-integration/fish/vendor_completions.d
# 24K ./shell-integration/fish
# 56K ./shell-integration
# 9.5K ./kitty/bin
# 8.3M ./kitty/install-tool
# 8.3M ./kitty
# 8.3M .
cat <<-EOF | tee -a ${DEST}/.zsh_aliases.d/003_kitty.zsh >/dev/null
alias ssh="kitty +kitten ssh"
EOF
# more kitty aliases
cat <<-EOF | tee -a ${DEST}/.zsh_aliases.d/003_kitty.zsh >/dev/null
alias kt="kitten transfer"
EOF
# end the kitty aliases
cat <<-EOF | tee -a ${DEST}/.zsh_aliases.d/003_kitty.zsh >/dev/null
fi
EOF
# Configuration for 'kitty +kitten ssh' aliased above to ssh
# for kitty terminal sessions
# Environment variables to set and files to copy on connection.
# https://sw.kovidgoyal.net/kitty/kittens/ssh/
mkdir -p ${KITTY_HOME}
cat <<-EOF | tee -a ${KITTY_HOME}/ssh.conf >/dev/null
# Copy the files and directories needed to setup some common tools
# copy .zshrc .vimrc .vim
# Setup some environment variables
# env SOME_VAR=x
# COPIED_VAR will have the same value on the remote host as it does locally
# env COPIED_VAR=_kitty_copy_env_var_
# Create some per hostname settings
# hostname someserver-*
# copy env-files
# env SOMETHING=else
# hostname someuser@somehost
# copy --dest=foo/bar some-file
# copy --glob some/files.*
EOF
# set up tmuxp like sessions
mkdir -p ${KITTY_HOME}/sessions
cat <<-EOF | tee ${DEST}/.config/kitty/sessions/startup.conf >/dev/null
# startup.conf
new_tab devuan-sdk
cd /space/code_repositories/decode-os/os-build-system
title vim
launch zsh -c 'nvim ../README.md'
launch zsh -c 'nvim console.sh'
launch zsh
enabled_layouts tall:bias=50;full_size=1
layout tall
new_tab other
cd ~
launch zsh
enabled_layouts tall:bias=50;full_size=1
layout tall
EOF
# Manual shell integration to work well with sub-shells, terminal multiplexers, containers
# requires kitty.conf 'shell-integration disabled' be set below.
# https://sw.kovidgoyal.net/kitty/shell-integration/#manual-shell-integration
cat <<-EOF | tee ${DEST}/.zshrc.d/002_kitty-shell.zsh >/dev/null
# Manual shell integration to work with sub-shells, tmux and containers.
if test -n "$KITTY_INSTALLATION_DIR"; then
export KITTY_SHELL_INTEGRATION="enabled"
autoload -Uz -- $KITTY_INSTALLATION_DIR/shell-integration/zsh/kitty-integration
kitty-integration
unfunction kitty-integration
fi
EOF
# kitty specific zsh function eq load a session file on startup.
cat <<-EOF | tee ${DEST}/.zshrc.d/002_kitty-functions.zsh >/dev/null
# # An emple function that loads a session file on startup.
# function kt_devuan-sdk() {
# export PROJECT_DIR=
# nohup kitty --session ~/.config/kitty/sessions/startup.conf & disown
# exit
# }
EOF
## KITTYCONF START
mkdir -p ${KITTY_HOME}
cat <<-EOF | tee ${KITTY_HOME}/kitty.conf >/dev/null
# vim:ft=kitty
# Performance - Keyboard to screen latency https://sw.kovidgoyal.net/kitty/performance/
input_delay 0
repaint_delay 2
sync_to_monitor no
wayland_enable_ime no
# https://github.com/tonsky/FiraCode#fira-code-free-monospaced-font-with-programming-ligatures
# Font settings (kitty +list-fonts --psnames | grep FiraCode | grep Retina)
font_family FiraCodeNerdFontComplete-Retina
font_features FiraCodeNerdFontComplete-Retina +cv04 +cv10 +ss04 +ss03 +cv25 +cv32 +cv28 +ss06 +ss07
bold_font FiraCodeNerdFontComplete-Bold
italic_font auto
bold_italic_font auto
font_size 11.5
disable_ligatures never
# adjust_line_height 1
# Mouse
copy_on_select yes
strip_trailing_spaces always
# Cursor
cursor_shape block
cursor_blink_interval 0
# Window layout
window_border_width 1px
hide_window_decorations no
# Bell
enable_audio_bell no
window_alert_on_bell yes
bell_on_tab no
# Tab Bar
tab_bar_edge top
tab_bar_style powerline
# tab_powerline_style angled
# tab_bar_min_tabs 1
# tab_bar_align left
# Advanced
EOF
# Choose this if not using zsh or you don't want manual shell integration
# # For manual shell integration above comment out the following
# cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf
# shell_integration enabled
# EOF
# For manual shell integration above uncomment the following
cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf >/dev/null
shell_integration disabled
EOF
# A bunch of people want auto-update in every 'app'
# and the others are unix users. Disable the update check completely.
cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf >/dev/null
update_check_interval 0
EOF
# default browser and other settings
cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf >/dev/null
# Default browser
open_url_with /usr/bin/brave-browser
# linux_display_server x11
# Background transparency
# https://lyz-code.github.io/blue-book/kitty/#make-the-background-transparent
background_opacity 0.85
EOF
cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf >/dev/null
####### Keyboard Shortcuts #######
## windows
map kitty_mod+enter new_window_with_cwd
map kitty_mod+n new_os_window_with_cwd
map kitty_mod+t new_tab_with_cwd
EOF
# https://lyz-code.github.io/blue-book/kitty/#Movement
cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf >/dev/null
## Movement
map kitty_mod+k scroll_line_up
map kitty_mod+j scroll_line_down
map kitty_mod+u scroll_page_up
map kitty_mod+d scroll_page_down
EOF
# scrollback buffer ctrl+shift+h
# https://lyz-code.github.io/blue-book/kitty/#the-scrollback-buffer
# https://github.com/kovidgoyal/kitty/issues/719
cat <<-'EOF' | tee -a ${KITTY_HOME}/kitty.conf >/dev/null
# Scrollback buffer
# https://sw.kovidgoyal.net/kitty/overview/#the-scrollback-buffer
# $(bash -c '...') Run everything in a shell taking the scrollback content on stdin
# $(-u NORC) Load plugins but not initialization files
# $(-c "map q :qa!<CR>") Close with $(q) key
# $(-c "autocmd TermOpen * normal G") On opening of the embedded terminal go to last line
# $(-c "terminal cat /proc/$$/fd/0 -") Open the embedded terminal and read stdin of the shell
# $(-c "set clipboard+=unnamedplus") Always use clipboard to yank/put instead of having to specify +
scrollback_pager bash -c 'nvim </dev/null -u NORC -c "map q :qa!<CR>" -c "autocmd TermOpen * normal G" -c "terminal cat /proc/$$/fd/0 -" -c "set clipboard+=unnamedplus" -c "call cursor(CURSOR_LINE, CURSOR_COLUMN)"'
# Infinite scrollback
scrollback_lines -1
scrollback_pager_history_size 0
EOF
# Some other mapping examples
# cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf
#
# ## Misc
# # map alt+ctrl+shift+g launch --cwd=current gitui
#
# ## Tab management
# map alt+c new_tab
# map kitty_mod+enter new_tab
#
# map alt+1 goto_tab 1
# map alt+2 goto_tab 2
# map alt+3 goto_tab 3
# map alt+4 goto_tab 4
# map alt+5 goto_tab 5
# map alt+6 goto_tab 6
# map alt+7 goto_tab 7
# map alt+8 goto_tab 8
# map alt+9 goto_tab 9
#
# ## Window management
# map alt+enter new_window_with_cwd
#
# map alt+v toggle_layout tall
# map alt+s toggle_layout grid
#
# map alt+h neighboring_window left
# map alt+j neighboring_window bottom
# map alt+k neighboring_window top
# map alt+l neighboring_window right
#
# map alt+shift+h move_window left
# map alt+shift+j move_window bottom
# map alt+shift+k move_window top
# map alt+shift+l move_window right
#
# # map alt+shift+1 move_window left
# # map alt+shift+2 move_window bottom
# # map alt+shift+3 move_window top
# # map alt+shift+4 move_window right
# # map alt+shift+5 move_window right
# # map alt+shift+6 move_window right
# # map alt+shift+7 move_window right
# # map alt+shift+8 move_window right
# # map alt+shift+9 move_window right
# map kitty_mod+f4 detach_window ask
# EOF
# Use kitty +kitten theme location
cat <<-EOF | tee -a ${KITTY_HOME}/kitty.conf >/dev/null
# BEGIN_KITTY_THEME
# Terminology Default
include current-theme.conf
# END_KITTY_THEME
EOF
## KITTYCONF END
## Themes
# The theme template for submissions.
# if the theme doesn't exist, it will be downloaded
# and put in the kitty themes directory
if [ ! -f ${KITTY_HOME}/theme-template.conf ]; then
echo "Downloading theme template"
wget -c -O ${KITTY_HOME}/theme-template.conf https://raw.githubusercontent.com/kovidgoyal/kitty-themes/master/template.conf
fi
cat <<-EOF | tee ${KITTY_HOME}/Nord.conf >/dev/null
# vim:ft=kitty
## name: Nord
## author: Eric N. Vander Weele
## upstream: https://www.nordtheme.com/
## blurb: Nord theme utilizing the full Frost and Aurora palette.
# Basic colors
foreground #d8dee9
background #2e3440
selection_foreground #d8dee9
selection_background #434c5e
# Cursor colors
cursor #d8dee9
cursor_text_color #3b4252
# URL underline color when hovering with mouse
url_color #0087bd
# Window border colors and terminal bell colors
active_border_color #81a1c1
inactive_border_color #4c566a
bell_border_color #88c0d0
visual_bell_color none
# Tab bar colors
active_tab_foreground #3b4252
active_tab_background #88c0d0
inactive_tab_foreground #e5e9f0
inactive_tab_background #4c566a
tab_bar_background #3b4252
tab_bar_margin_color none
# Mark colors (marked text in the terminal)
mark1_foreground #3b4252
mark1_background #88c0d0
mark2_foreground #3b4252
mark2_background #bf616a
mark3_foreground #3b4252
mark3_background #ebcb8b
# The basic 16 colors
# black
color0 #3b4252
color8 #4c566a
# red
color1 #bf616a
color9 #bf616a
# green
color2 #a3be8c
color10 #a3be8c
# yellow
color3 #ebcb8b
color11 #d08770
# blue
color4 #81a1c1
color12 #5e81ac
# magenta
color5 #b48ead
color13 #b48ead
# cyan
color6 #88c0d0
color14 #8fbcbb
# white
color7 #e5e9f0
color15 #eceff4
EOF
cat <<-EOF | tee ${KITTY_HOME}/Nord-custom.conf >/dev/null
# vim:ft=kitty
# Nord Colorscheme for Kitty
# Based on:
# - https://gist.github.com/marcusramberg/64010234c95a93d953e8c79fdaf94192
# - https://github.com/arcticicestudio/nord-hyper
foreground #e0def4
background #12121e
selection_foreground #12121e
selection_background #FFFACD
url_color #9ccfd8
cursor #cccccc
# black
color0 #3B4252
color8 #4C566A
# red
color1 #FF789E
color9 #FF789E
# green
color2 #A3BE8C
color10 #A3BE8C
# yellow
color3 #f6c177
color11 #f6c177
# blue
color4 #81A1C1
color12 #81A1C1
# magenta
color5 #c4a7e7
color13 #c4a7e7
# cyan
color6 #9ccfd8
color14 #8FBCBB
# white
color7 #E5E9F0
color15 #ECEFF4
# Windows
active_border_color #f6c177
inactive_border_color #12121e
# Tabs
active_tab_foreground #12121e
active_tab_background #9ccfd8
active_tab_font_style bold
inactive_tab_foreground #e0def4
inactive_tab_background #12121e
inactive_tab_font_style normal
# ####### Keyboard Shortcuts #######
#
# ## Misc
# # map alt+ctrl+shift+g launch --cwd=current gitui
#
# ## Tab management
# map alt+c new_tab
# map kitty_mod+enter new_tab
#
# map alt+1 goto_tab 1
# map alt+2 goto_tab 2
# map alt+3 goto_tab 3
# map alt+4 goto_tab 4
# map alt+5 goto_tab 5
# map alt+6 goto_tab 6
# map alt+7 goto_tab 7
# map alt+8 goto_tab 8
# map alt+9 goto_tab 9
#
# ## Window management
# map alt+enter new_window_with_cwd
#
# map alt+v toggle_layout tall
# map alt+s toggle_layout grid
#
# map alt+h neighboring_window left
# map alt+j neighboring_window bottom
# map alt+k neighboring_window top
# map alt+l neighboring_window right
#
# map alt+shift+h move_window left
# map alt+shift+j move_window bottom
# map alt+shift+k move_window top
# map alt+shift+l move_window right
#
# # map alt+shift+1 move_window left
# # map alt+shift+2 move_window bottom
# # map alt+shift+3 move_window top
# # map alt+shift+4 move_window right
# # map alt+shift+5 move_window right
# # map alt+shift+6 move_window right
# # map alt+shift+7 move_window right
# # map alt+shift+8 move_window right
# # map alt+shift+9 move_window right
# map kitty_mod+f4 detach_window ask
EOF
cat <<-EOF | tee ${KITTY_HOME}/Dimmed\ Monokai.conf >/dev/null
# vim:ft=kitty
background #1e1e1e
foreground #b8bcb9
cursor #eee
selection_background #efcc00
color0 #3a3c43
color8 #888987
color1 #be3e48
color9 #fb001e
color2 #869a3a
color10 #0e712e
color3 #c4a535
color11 #c37033
color4 #4e76a1
color12 #176ce3
color5 #855b8d
color13 #fb0067
color6 #568ea3
color14 #2d6f6c
color7 #b8bcb9
color15 #fcffb8
selection_foreground #1e1e1e
EOF
cat <<-EOF | tee ${KITTY_HOME}/Adwaita\ dark.conf >/dev/null
# vim:ft=kitty
## name: Adwaita dark
## license: MIT
## author: Emil Löfquist (https://github.com/ewal)
## upstream: https://github.com/ewal/kitty-adwaita/blob/main/adwaita_dark.conf
## blurb: Adwaita dark - based on https://github.com/Mofiqul/adwaita.nvim
background #1d1d1d
foreground #deddda
selection_background #303030
selection_foreground #c0bfbc
url_color #1a5fb4
wayland_titlebar_color system
macos_titlebar_color system
cursor #deddda
cursor_text_color #1d1d1d
active_border_color #4f4f4f
inactive_border_color #282828
bell_border_color #ed333b
visual_bell_color none
active_tab_background #242424
active_tab_foreground #fcfcfc
inactive_tab_background #303030
inactive_tab_foreground #b0afac
tab_bar_background none
tab_bar_margin_color none
color0 #1d1d1d
color1 #ed333b
color2 #57e389
color3 #ff7800
color4 #62a0ea
color5 #9141ac
color6 #5bc8af
color7 #deddda
color8 #9a9996
color9 #f66151
color10 #8ff0a4
color11 #ffa348
color12 #99c1f1
color13 #dc8add
color14 #93ddc2
color15 #f6f5f4
EOF
cat <<-EOF | tee ${KITTY_HOME}/Catppuccin-Macchiato.config >/dev/null
# vim:ft=kitty
## name: Catppuccin-Macchiato
## author: Pocco81 (https://github.com/Pocco81)
## license: MIT
## upstream: https://github.com/catppuccin/kitty/blob/main/macchiato.conf
## blurb: Soothing pastel theme for the high-spirited!
# The basic colors
foreground #CAD3F5
background #24273A
selection_foreground #24273A
selection_background #F4DBD6
# Cursor colors
cursor #F4DBD6
cursor_text_color #24273A
# URL underline color when hovering with mouse
url_color #F4DBD6
# Kitty window border colors
active_border_color #B7BDF8
inactive_border_color #6E738D
bell_border_color #EED49F
# OS Window titlebar colors
wayland_titlebar_color system
macos_titlebar_color system
# Tab bar colors
active_tab_foreground #181926
active_tab_background #C6A0F6
inactive_tab_foreground #CAD3F5
inactive_tab_background #1E2030
tab_bar_background #181926
# Colors for marks (marked text in the terminal)
mark1_foreground #24273A
mark1_background #B7BDF8
mark2_foreground #24273A
mark2_background #C6A0F6
mark3_foreground #24273A
mark3_background #7DC4E4
# The 16 terminal colors
# black
color0 #494D64
color8 #5B6078
# red
color1 #ED8796
color9 #ED8796
# green
color2 #A6DA95
color10 #A6DA95
# yellow
color3 #EED49F
color11 #EED49F
# blue
color4 #8AADF4
color12 #8AADF4
# magenta
color5 #F5BDE6
color13 #F5BDE6
# cyan
color6 #8BD5CA
color14 #8BD5CA
# white
color7 #B8C0E0
color15 #A5ADCB
EOF
cat <<-EOF | tee ${KITTY_HOME}/Tokyo\ Night\ Moon.conf >/dev/null
# vim:ft=kitty
## name: Tokyo Night Moon
## license: MIT
## author: Folke Lemaitre
## upstream: https://github.com/folke/tokyonight.nvim/raw/main/extras/kitty/tokyonight_moon.conf
background #222436
foreground #c8d3f5
selection_background #2d3f76
selection_foreground #c8d3f5
url_color #4fd6be
cursor #c8d3f5
cursor_text_color #222436
# Tabs
active_tab_background #82aaff
active_tab_foreground #1e2030
inactive_tab_background #2f334d
inactive_tab_foreground #545c7e
#tab_bar_background #1b1d2b
# Windows
active_border_color #82aaff
inactive_border_color #2f334d
# normal
color0 #1b1d2b
color1 #ff757f
color2 #c3e88d
color3 #ffc777
color4 #82aaff
color5 #c099ff
color6 #86e1fc
color7 #828bb8
# bright
color8 #444a73
color9 #ff757f
color10 #c3e88d
color11 #ffc777
color12 #82aaff
color13 #c099ff
color14 #86e1fc
color15 #c8d3f5
# extended colors
color16 #ff966c
color17 #c53b53
EOF
cat <<-EOF
Get more themes or switch themes with:
$ kitty +kitten themes
which adds:
# BEGIN_KITTY_THEME
# Nord
include current-theme.conf
# END_KITTY_THEME%
to the end of the ${KITTY_HOME}/kitty.conf file
and copies the chosen theme to current-theme.config
so don't use 'ln -sf' to change the theme.
EOF