Compare commits

...

7 Commits

Author SHA1 Message Date
ddb279da7b kitty:daemon: Write to log file 2025-08-26 16:54:55 +02:00
07428c661d kitty:daemon: Support optional instance group name 2025-08-26 13:43:03 +02:00
a7e4c2c770 kitty:daemon: Use TMPDIR and support multi-user 2025-08-26 13:41:18 +02:00
c09ed22389 i3: Move kitty daemonization into own script 2025-08-26 13:06:08 +02:00
1f6fb2abf7 zsh:glog: Bind Ctrl-s to toggle-sort
When searching for a specific commit in a long history the chronological
sorting can sometimes be annoying. Map ctrl-s to toggle-sort so that the
best result can be at the top.
2025-08-24 20:57:23 +02:00
b47c91bb5f zsh:glog: Use Ctrl-Alt for preview bindings
This makes it more consistent with the preview scroll bindings.
2025-08-24 20:57:17 +02:00
fec954c30c zsh:glog: Move header into variable 2025-08-24 20:57:10 +02:00
5 changed files with 56 additions and 15 deletions

View File

@@ -36,18 +36,11 @@ set $TERM_CMD_FLAG
# a single sprite cache on the GPU"[^1], so that startup is almost instant.
#
# For this to work best, launch one hidden "daemon" instance at startup so that
# the kitty process is always running, even when no OS windows exists.
#
# NOTE: `--start-as hidden` needs kitty 0.42.0 or later.
#
# Additionally allow remote_control over a socket, so that kitty-cwd works.
# the kitty process is always running, even when no OS windows exists. See the
# daemon.sh script in .config/kitty.
#
# [^1]: kitty(1)
exec --no-startup-id $TERMINAL \
--start-as hidden \
--detach \
-o allow_remote_control=socket-only \
--listen-on unix:/tmp/mykitty
exec --no-startup-id kitty-daemon
# Multi monitor support
exec_always --no-startup-id ~/.config/i3/monitor-setup.sh &

34
.config/kitty/daemon.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 Julian Prein
#
# Usage: kitty-daemon [GROUP_NAME]
#
# Daemonize kitty by launching one hidden instance that new invocations can use
# to create new OS windows. This makes kitty startup a lot faster since all
# windows can now share a single CPU process and GPU sprite cache. Additionally
# allow remote_control over a socket, so that kitty-cwd works.
#
# To launch new invocations using the daemon created by this script use:
#
# kitty --single-instance
#
# You can pass an optional instance-group as first parameter. In that case use:
#
# kitty --single-instance --instance-group <NAME>
#
# NOTE: `--start-as hidden` needs kitty 0.42.0 or later.
TMP_DIR="${TMPDIR:-/tmp}/kitty.$USER"
mkdir -p "$TMP_DIR"
name="kitty${1:+-$1}"
kitty \
--single-instance \
${1:+--instance-group "$1"} \
--start-as hidden \
--detach \
--detached-log "$(mktemp -p "$TMP_DIR" "$name.XXXXXX.log")" \
-o allow_remote_control=socket-only \
--listen-on unix:"$TMP_DIR/$name.sock"

View File

@@ -2,12 +2,16 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 Julian Prein
#
# Usage: kitty-cwd [GROUP_NAME]
#
# Print the current working directory of the focused kitty window. Returns 4 if
# none exist or is focused.
socket_path="${TMPDIR:-/tmp}/kitty.$USER/kitty${1:+-$1}.sock"
# NOTE: the backticks are used for hacky line-continuation, taken from
# https://stackoverflow.com/a/7729087/2092762c9
kitten @ --to unix:/tmp/mykitty ls \
kitten @ --to unix:"$socket_path" ls \
| jq -er ".[]`
` | select(.is_focused).tabs.[]`
` | select(.is_focused).windows.[]`

View File

@@ -105,6 +105,7 @@ local -A binds=(
"end" "last"
"ctrl-d" "half-page-down"
"ctrl-u" "half-page-up"
"ctrl-s" "toggle-sort"
"ctrl-t" "toggle-track"
# Keep the current line selected while deleting the query
"bspace" "track-current+backward-delete-char"
@@ -120,11 +121,11 @@ local -A binds=(
# TODO: This assumes less to be used in core.pager
"enter" "execute@$fzf_preview[patch] | $pager -+F@"
# Preview stats
"ctrl-s" "change-preview($fzf_preview[stat])"
"ctrl-alt-s" "change-preview($fzf_preview[stat])"
# Preview patch
"ctrl-p" "change-preview($fzf_preview[patch])"
"ctrl-alt-p" "change-preview($fzf_preview[patch])"
# Files only
"ctrl-f" "change-preview($fzf_preview[files_only])"
"ctrl-alt-f" "change-preview($fzf_preview[files_only])"
# For ctrl-space see below
)
@@ -132,13 +133,21 @@ local -A binds=(
# fzf_preview[stat] in this case). It does not really make sense to pass
# it to `git log` but can be an indicator for the preview function
local color_brown=$'\e[38;5;144m'
local color_grey=$'\e[38;5;59m'
local header=""
header+="${color_brown}Enter${color_grey}: fullscreen, "
header+="${color_brown}C-y${color_grey}: yank hash, "
header+="${color_brown}C-Space${color_grey}: cycle preview, "
header+="${color_brown}C-A-[spf]${color_grey}: preview stats/patch/files"
local -a fzf_args=(
# Understand ansi color escape sequences.
"--ansi"
# Expand the binds array in the format "key1:value1,key2:value2".
"--bind" "${(@kj:,:)binds/(#m)*/$MATCH:$binds[$MATCH]}"
# Display key-bindings in a sticky header
"--header" $'\e[38;5;144mEnter\e[38;5;59m: fullscreen, \e[38;5;144mC-y\e[38;5;59m: yank hash, \e[38;5;144mC-Space\e[38;5;59m: cycle preview, \e[38;5;144mC-[spf]\e[38;5;59m: preview stats/patch/files'
"--header" "$header"
# Keep header above prompt line
"--header-first"
# Execute git show on the commit as preview.

1
.local/bin/kitty-daemon Symbolic link
View File

@@ -0,0 +1 @@
../../.config/kitty/daemon.sh