diff options
| author | David Moc <personal@cdatgoose.org> | 2026-05-24 11:48:07 +0200 |
|---|---|---|
| committer | David Moc <personal@cdatgoose.org> | 2026-05-24 11:48:07 +0200 |
| commit | 5fb19f10389b70ee2389755106092a9ef6c64598 (patch) | |
| tree | 969eb0466de581cb14aa09f751a95138620fc720 /kitty | |
Go
Diffstat (limited to 'kitty')
| -rw-r--r-- | kitty/kitty.conf | 190 | ||||
| -rwxr-xr-x | kitty/ssh_picker.sh | 202 |
2 files changed, 392 insertions, 0 deletions
diff --git a/kitty/kitty.conf b/kitty/kitty.conf new file mode 100644 index 0000000..bfd1500 --- /dev/null +++ b/kitty/kitty.conf @@ -0,0 +1,190 @@ +# ============================================================ +# ~/.config/kitty/kitty.conf — gruvbox dark +# pairs with .tmux.conf +# ============================================================ + + +# ------------------------------------------------------------ +# font +# ------------------------------------------------------------ +font_family JetBrains Mono Regular +bold_font JetBrains Mono Bold +italic_font JetBrains Mono Italic +bold_italic_font JetBrains Mono Bold Italic + +font_size 13.0 + +# fine-tune spacing +adjust_line_height 2 +adjust_column_width 0 +disable_ligatures never + + +# ------------------------------------------------------------ +# gruvbox dark colour scheme +# ------------------------------------------------------------ + +# background / foreground +background #282828 +foreground #ebdbb2 +cursor #ebdbb2 +background_opacity 0.88 +# selection +selection_background #d79921 +selection_foreground #282828 + +# url underline +url_color #83a598 + +# black +color0 #282828 +color8 #928374 + +# red +color1 #cc241d +color9 #fb4934 + +# green +color2 #98971a +color10 #b8bb26 + +# yellow +color3 #d79921 +color11 #fabd2f + +# blue +color4 #458588 +color12 #83a598 + +# purple +color5 #b16286 +color13 #d3869b + +# cyan / aqua +color6 #689d6a +color14 #8ec07c + +# white +color7 #a89984 +color15 #ebdbb2 + + +# ------------------------------------------------------------ +# cursor +# ------------------------------------------------------------ +cursor_shape block +cursor_blink_interval 0 + + +# ------------------------------------------------------------ +# scrollback +# ------------------------------------------------------------ +scrollback_lines 10000 +scrollback_pager less --chop-long-lines --RAW-CONTROL-CHARS +INPUT_LINE_NUMBER + + +# ------------------------------------------------------------ +# window / padding +# ------------------------------------------------------------ +window_padding_width 8 +placement_strategy center +hide_window_decorations no +remember_window_size yes +initial_window_width 220c +initial_window_height 50c + + +# ------------------------------------------------------------ +# tab bar — matches tmux status style +# ------------------------------------------------------------ +tab_bar_edge bottom +tab_bar_style powerline +tab_powerline_style slanted +tab_bar_background #3c3836 +tab_bar_margin_color #3c3836 + +tab_title_template "{index}:{title}" +active_tab_title_template "{index}:{title}" + +active_tab_foreground #282828 +active_tab_background #83a598 +active_tab_font_style bold + +inactive_tab_foreground #a89984 +inactive_tab_background #3c3836 +inactive_tab_font_style normal + + +# ------------------------------------------------------------ +# bell +# ------------------------------------------------------------ +enable_audio_bell no +visual_bell_duration 0.0 + + +# ------------------------------------------------------------ +# performance +# ------------------------------------------------------------ +repaint_delay 10 +input_delay 3 +sync_to_monitor yes +background_blur 19 + +# ------------------------------------------------------------ +# mouse +# ------------------------------------------------------------ +mouse_hide_wait 3.0 +focus_follows_mouse no +copy_on_select clipboard + + +# ------------------------------------------------------------ +# keyboard shortcuts +# ------------------------------------------------------------ +# clear defaults +clear_all_shortcuts no + +# copy / paste +map ctrl+shift+c copy_to_clipboard +map ctrl+shift+v paste_from_clipboard + +# font size +map ctrl+shift+equal change_font_size all +1.0 +map ctrl+shift+minus change_font_size all -1.0 +map ctrl+shift+0 change_font_size all 0 + +# tabs +map ctrl+shift+t new_tab_with_cwd +map ctrl+shift+w close_tab +map ctrl+shift+right next_tab +map ctrl+shift+left previous_tab +map ctrl+shift+1 goto_tab 1 +map ctrl+shift+2 goto_tab 2 +map ctrl+shift+3 goto_tab 3 +map ctrl+shift+4 goto_tab 4 +map ctrl+shift+5 goto_tab 5 + +# windows (kitty splits — complement to tmux panes) +map ctrl+shift+enter new_window_with_cwd +map ctrl+shift+] next_window +map ctrl+shift+[ previous_window + +# scrollback +map ctrl+shift+up scroll_line_up +map ctrl+shift+down scroll_line_down +map ctrl+shift+page_up scroll_page_up +map ctrl+shift+page_down scroll_page_down +map ctrl+shift+home scroll_home +map ctrl+shift+end scroll_end + +# reload config +map ctrl+shift+F5 load_config_file + +map ctrl+shift+s launch --title="ssh picker" --hold bash ~/.config/kitty/ssh_picker.sh + + + +# ------------------------------------------------------------ +# shell integration +# ------------------------------------------------------------ +shell_integration enabled diff --git a/kitty/ssh_picker.sh b/kitty/ssh_picker.sh new file mode 100755 index 0000000..6ad6e3a --- /dev/null +++ b/kitty/ssh_picker.sh @@ -0,0 +1,202 @@ +#!/usr/bin/env bash +# ~/.config/kitty/ssh_picker.sh +# Launched by kitty as an overlay window. +# Reads servers from ~/.ssh/config (Host entries) and lets +# you fuzzy-filter with arrow keys, then opens kitten ssh. +# +# Dependencies: none beyond bash + standard coreutils. +# Optional: fzf — if present it takes over the picker UI. + +set -euo pipefail + +# ------------------------------------------------------------ +# config — edit these or let them fall through to ~/.ssh/config +# ------------------------------------------------------------ +SSH_CONFIG="${HOME}/.ssh/config" +TERM_FALLBACK="xterm-256color" + +# ------------------------------------------------------------ +# gruvbox dark ANSI helpers +# ------------------------------------------------------------ +RESET=$'\e[0m' +BOLD=$'\e[1m' +DIM=$'\e[2m' + +GB_BG=$'\e[48;2;40;40;40m' # #282828 +GB_BG1=$'\e[48;2;60;56;54m' # #3c3836 +GB_BG2=$'\e[48;2;80;73;69m' # #504945 +GB_YELLOW=$'\e[38;2;250;189;47m' # #fabd2f +GB_BLUE=$'\e[38;2;131;165;152m' # #83a598 +GB_GREEN=$'\e[38;2;184;187;38m' # #b8bb26 +GB_RED=$'\e[38;2;251;73;52m' # #fb4934 +GB_ORANGE=$'\e[38;2;254;128;25m' # #fe8019 +GB_FG=$'\e[38;2;235;219;178m' # #ebdbb2 +GB_DIM=$'\e[38;2;168;153;132m' # #a89984 + +# ------------------------------------------------------------ +# parse servers +# ------------------------------------------------------------ +get_servers() { + local servers=() + + # pull Host entries from ~/.ssh/config (skip wildcards) + if [[ -f "$SSH_CONFIG" ]]; then + while IFS= read -r line; do + if [[ "$line" =~ ^[Hh]ost[[:space:]]+([^*?]+)$ ]]; then + local host="${BASH_REMATCH[1]// /}" + [[ -n "$host" ]] && servers+=("$host") + fi + done < "$SSH_CONFIG" + fi + + # fallback examples if config is empty + if [[ ${#servers[@]} -eq 0 ]]; then + servers=( + "contabo server" + ) + fi + + printf '%s\n' "${servers[@]}" +} + +# ------------------------------------------------------------ +# fzf path (preferred) +# ------------------------------------------------------------ +if command -v fzf &>/dev/null; then + selected=$(get_servers | fzf \ + --prompt=" ssh " \ + --pointer=">" \ + --marker="*" \ + --height=40% \ + --layout=reverse \ + --border=rounded \ + --info=inline \ + --color="dark,\ +bg:#282828,\ +bg+:#3c3836,\ +fg:#ebdbb2,\ +fg+:#fbf1c7,\ +hl:#fabd2f,\ +hl+:#fabd2f,\ +border:#504945,\ +prompt:#83a598,\ +pointer:#fe8019,\ +marker:#b8bb26,\ +spinner:#d3869b,\ +header:#a89984,\ +info:#a89984" \ + --header=" ctrl+c to cancel" \ + --preview="echo {} | xargs -I% sh -c 'grep -A10 \"^Host %$\" ~/.ssh/config 2>/dev/null || echo \"no config entry\"'" \ + --preview-window="right:40%:wrap" \ + 2>/dev/null) || exit 0 + + [[ -z "$selected" ]] && exit 0 + TERM="$TERM_FALLBACK" kitten ssh "$selected" + exit 0 +fi + +# ------------------------------------------------------------ +# built-in picker (no fzf) +# ------------------------------------------------------------ +mapfile -t SERVERS < <(get_servers) +TOTAL=${#SERVERS[@]} +SELECTED=0 +QUERY="" +FILTERED=("${SERVERS[@]}") + +draw() { + clear + printf '%s' "${GB_BG}" + printf '\n' + printf ' %s%s ssh picker%s\n' "${GB_YELLOW}${BOLD}" "" "${RESET}" + printf ' %s%s%s\n\n' "${GB_DIM}" "arrow keys to navigate, enter to connect, esc to quit" "${RESET}" + + # search bar + printf ' %ssearch:%s %s%s%s\n\n' \ + "${GB_DIM}" "${RESET}" \ + "${GB_FG}${BOLD}" "${QUERY}" "${RESET}" + + # server list + local i=0 + for srv in "${FILTERED[@]}"; do + if [[ $i -eq $SELECTED ]]; then + printf ' %s%s > %s%s\n' "${GB_BG1}${GB_ORANGE}${BOLD}" "" "$srv" "${RESET}" + else + printf ' %s %s%s\n' "${GB_DIM}" "$srv" "${RESET}" + fi + (( i++ )) + done + + printf '\n %s%s hosts found • install fzf for preview support%s\n' \ + "${GB_DIM}" "${#FILTERED[@]}" "${RESET}" +} + +filter() { + FILTERED=() + SELECTED=0 + for srv in "${SERVERS[@]}"; do + if [[ -z "$QUERY" || "${srv,,}" == *"${QUERY,,}"* ]]; then + FILTERED+=("$srv") + fi + done +} + +# hide cursor +tput civis +trap 'tput cnorm; clear' EXIT + +while true; do + draw + + # read a single keypress (handles escape sequences) + IFS= read -r -s -N1 key + + # check for escape sequences (arrow keys) + if [[ "$key" == $'\e' ]]; then + IFS= read -r -s -N1 -t 0.1 k2 || true + if [[ "$k2" == "[" ]]; then + IFS= read -r -s -N1 -t 0.1 k3 || true + case "$k3" in + A) # up + (( SELECTED > 0 )) && (( SELECTED-- )) + ;; + B) # down + (( SELECTED < ${#FILTERED[@]} - 1 )) && (( SELECTED++ )) + ;; + esac + else + # plain escape — quit + exit 0 + fi + continue + fi + + case "$key" in + $'\n'|$'\r') + [[ ${#FILTERED[@]} -eq 0 ]] && continue + tput cnorm + clear + host="${FILTERED[$SELECTED]}" + printf '%sconnecting to %s%s%s...\n\n' \ + "${GB_DIM}" "${GB_BLUE}${BOLD}" "$host" "${RESET}" + TERM="$TERM_FALLBACK" kitten ssh "$host" + exit 0 + ;; + $'\x7f'|$'\b') + # backspace + QUERY="${QUERY%?}" + filter + ;; + $'\x03') + # ctrl+c + exit 0 + ;; + *) + # printable character — append to query + if [[ "$key" =~ ^[[:print:]]$ ]]; then + QUERY+="$key" + filter + fi + ;; + esac +done |
