4 Commits
Author SHA1 Message Date
BlackAngelTV 9c1bf4d84f build: add an Arch package for the FWS kitty
Installing the branch system-wide meant copying binaries by hand. Provide a
PKGBUILD that builds the branch and installs kitty and kitten in /usr/bin so
pacman can install and update it, with instructions for a local repository.
2026-11-06 08:41:18 +01:00
BlackAngelTV 93055004a9 docs: add a French README covering the whole workflow
The branch failed on another machine in ways the existing guides did not
explain, from an unextracted dependency bundle to the generated Go files
that only ./dev.sh build creates. Document prerequisites, build, launch, the
file manager, tests, packaging and pulling on a new machine in one place.
2026-11-06 08:41:18 +01:00
BlackAngelTV 4fb1402d9e feat(file-manager): open files in a full-window editor tab
Enter on a file handed the editor command to the shell, so the panel closed
and had to be reopened, and a docked panel ran the editor squeezed into the
dock. Delegate to kitty's edit protocol instead: the editor opens in a new
tab with the whole window and the panel is redrawn with the same selection
when it exits.

The editor now comes from kitty's editor option. file-manager's editor,
open_with_sudo and --open-here are kept but ignored so existing configs and
mappings keep loading.
2026-11-06 08:41:18 +01:00
BlackAngelTV a12a05e666 fix(build): fetch the dependency bundle when its Python is missing
dependencies/ is gitignored, so a fresh clone has none, but a working tree
can keep the folder with only the cached tarball. Checking for the folder
skipped the download and the build then died with a cryptic missing-Python
error. Check the bundle Python itself so an incomplete bundle is fetched.
2026-11-06 08:41:18 +01:00
8 changed files with 574 additions and 164 deletions

No files matched your search

+341
View File
@@ -0,0 +1,341 @@
# FWS-Kitty
FWS-Kitty est le fork **FWS** de [kitty](https://sw.kovidgoyal.net/kitty/), un
terminal GPU rapide et riche en fonctionnalités. Le fork ajoute un
**gestionnaire de fichiers** (`kitten file-manager`) : un panneau latéral
pilotable au clavier qui change le répertoire courant du shell, crée, renomme et
supprime des entrées, et ouvre les fichiers dans l'éditeur.
Ce document décrit tout le cycle de vie du projet : récupérer le code, compiler,
lancer, utiliser l'explorateur, tester, construire le paquet Arch et dépanner.
`DEV.md` reste le guide de développement condensé, `README.asciidoc` est le
README d'origine de kitty.
## Contenu de la branche `feat/file-manager-panel`
| Chemin | Rôle |
| --- | --- |
| `kittens/file_manager/main.go` | Interface du panneau (rendu, touches, souris, actions fichiers) |
| `kittens/file_manager/main.py` | Définition des options, des raccourcis et du résultat renvoyé au shell |
| `kittens/file_manager/main_test.go` | Tests unitaires des fonctions pures |
| `kittens/file_manager/cli_generated.go`, `conf_generated.go` | Générés à la compilation, **non versionnés** |
| `tools/cmd/tool/main.go` | Enregistre `kitten file-manager` dans le binaire `kitten` |
| `docs/kittens/file-manager.rst` | Documentation utilisateur du panneau |
| `packaging/PKGBUILD`, `packaging/README.md` | Paquet pacman `fws-kitty` |
Les fichiers `*_generated.go` sont listés dans `.gitignore` : ils sont produits
par le code de génération à chaque `./dev.sh build`. Un `go build ./...` lancé
avant cette étape échoue avec `undefined: create_cmd` ou `undefined: Options`,
c'est normal.
## Prérequis
- **Linux x86_64 ou aarch64** (Arch Linux recommandé : c'est la cible du fork).
Windows et macOS ne compilent pas nativement, voir la section Docker.
- **Python >= 3.12** (voir `pyproject.toml`).
- **Go >= 1.26** (voir `go.mod`).
- Un serveur graphique X11 ou Wayland : le panneau s'affiche dans une fenêtre
kitty, il n'existe pas de mode texte seul.
Sur Arch Linux, tous les paquets de compilation :
```sh
sudo pacman -S --needed base-devel git go python \
harfbuzz zlib libpng lcms2 xxhash openssl shader-slang \
pixman cairo freetype2 fontconfig libcanberra systemd-libs simde \
libx11 libxcb libxrandr libxinerama libxcursor libxi libxrender \
xorgproto libxkbcommon libxkbcommon-x11 mesa dbus \
wayland wayland-protocols wayland-utils tar xz rsync which file
```
Pour le paquet Arch, `makepkg` a besoin en plus de `pkgconf` et `ncurses`.
## Récupérer le code
```sh
git clone <url-du-depot> FWS-Kitty
cd FWS-Kitty
git checkout feat/file-manager-panel
git pull
```
Le dépôt est normalisé en **LF** par `.gitattributes`. Si vous voyez des erreurs
du type `dev.sh: $'\r': command not found`, corrigez la copie de travail :
```sh
git config core.autocrlf false
git rm --cached -r -q . && git reset --hard
```
`packaging/` doit être présent après le `git pull` : sans lui, la section
« Paquet Arch » est impossible. Si le dossier manque, la branche n'a pas été
poussée complètement.
## Compiler
Tout passe par `./dev.sh`, qui télécharge un bundle de dépendances précompilées
(Python, pkg-config, Sphinx, polices…) dans `dependencies/`, puis appelle
`setup.py`.
```sh
./dev.sh deps # une seule fois, ou après une erreur de dépendances
./dev.sh build
```
`./dev.sh build` compile le C, génère le code Go (dont la configuration et la
ligne de commande du gestionnaire de fichiers), puis compile les kittens et les
outils. Les binaires finaux sont :
```sh
kitty/launcher/kitty # le terminal
kitty/launcher/kitten # le lanceur de kittens (dont file-manager)
```
Options utiles :
```sh
./dev.sh build --debug # symboles de debug
./dev.sh build --debug --sanitize
./dev.sh build -h # toutes les options
```
`dependencies/` est local et ignoré par git : il n'est jamais récupéré par un
`git pull`, et il peut exister sous forme de simple archive téléchargée. Depuis
cette version, `build` vérifie la présence du Python du bundle et relance
automatiquement `deps` s'il manque. En cas de doute :
```sh
rm -rf dependencies
./dev.sh deps && ./dev.sh build
```
Pour lancer les binaires sans chemin complet, ajoutez `kitty/launcher` au
`PATH`, ou créez des liens symboliques :
```sh
ln -s "$PWD/kitty/launcher/kitty" ~/.local/bin/kitty
ln -s "$PWD/kitty/launcher/kitten" ~/.local/bin/kitten
```
Le binaire retrouve ses sources par le chemin où `./dev.sh build` a été lancé :
si le dossier est déplacé, faites `make clean && ./dev.sh build`.
## Lancer kitty
```sh
./kitty/launcher/kitty
```
Vérification rapide sans interface graphique :
```sh
./kitty/launcher/kitty --version # kitty 0.50.0 ...
./kitty/launcher/kitten --version # kitten 0.50.0 ...
```
Sous WSL2, activez WSLg (Windows 11) pour obtenir une fenêtre, sinon exportez un
`DISPLAY` vers un serveur X. Dans un conteneur, montez le socket X11 ou le
socket Wayland ; une image sans affichage ne peut pas montrer le panneau.
### Docker (depuis Windows ou macOS)
`Dockerfile.arch` fournit un Arch Linux avec toutes les dépendances :
```sh
docker build -f Dockerfile.arch -t kitty-arch-dev .
docker run --rm -v "$PWD:/src" -w /src kitty-arch-dev sh dev.sh build
docker run --rm -it -v "$PWD:/src" -w /src kitty-arch-dev ./kitty/launcher/kitty
```
Sous Git Bash, préfixez par `MSYS_NO_PATHCONV=1` pour que `/src` ne soit pas
réécrit en chemin Windows. Le conteneur n'a pas d'affichage par défaut.
## Utiliser l'explorateur de fichiers
Le panneau doit tourner **dans kitty** : c'est un kitten, pas un programme
autonome. Depuis un shell lancé dans kitty :
```sh
kitten file-manager # répertoire courant
kitten file-manager ~/Projets # répertoire de départ
kitten file-manager --show-hidden
```
Raccourci pour l'avoir en permanence dans un dock latéral, à ajouter dans
`~/.config/kitty/kitty.conf` :
```conf
map ctrl+shift+e launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager
```
Un fichier validé s'ouvre dans un nouvel onglet, donc en pleine fenêtre même
depuis un dock, et le panneau reprend la main à la fermeture de l'éditeur. En
revanche, kitty ne rend jamais le résultat d'un `launch --type=window-dock` au
shell : valider un répertoire dans un dock ne peut donc pas faire de `cd`.
### Raccourcis par défaut
| Touche | Action |
| --- | --- |
| `Entrée` | Change le répertoire du shell si la sélection est un répertoire, sinon ouvre le fichier dans l'éditeur, dans un nouvel onglet ; le panneau revient à la fermeture de l'éditeur |
| `→` / `L` | Entre dans le répertoire sélectionné sans toucher au shell |
| `←` / `Retour arrière` / `H` | Remonte au répertoire parent |
| `Ctrl+Entrée` / `C` | Déplace le shell vers le répertoire affiché, sans tenir compte de la sélection |
| `↑` / `K`, `↓` / `J` | Déplace la sélection |
| `Page préc.` / `Ctrl+B`, `Page suiv.` / `Ctrl+F` | Déplace la sélection d'une page |
| `Début` / `G`, `Fin` / `Maj+G` | Première / dernière entrée |
| `N` | Crée un fichier (nom saisi dans la ligne d'état) |
| `Maj+N` | Crée un répertoire |
| `R` | Renomme l'entrée sélectionnée |
| `D` | Supprime après confirmation par `Y` (jamais récursivement) |
| `Y` | Copie le chemin dans le presse-papiers |
| `.` | Affiche ou masque les entrées cachées |
| `Ctrl+R` | Recharge le répertoire |
| `Échap` / `Q` | Ferme sans rien changer |
Un clic gauche sélectionne une entrée. Tous les raccourcis sont redéfinissables.
### Limites à connaître
- `Entrée` et `Ctrl+Entrée` agissent sur la fenêtre qui a lancé le panneau. Dans
un dock ou un panneau du bureau, le changement de répertoire n'a personne à
qui s'appliquer : lancez l'explorateur depuis un shell pour `cd`.
- L'éditeur s'ouvre toujours dans un nouvel onglet, plein écran ; fermer
l'éditeur referme l'onglet et rend le panneau tel qu'il était.
- L'édition passe par kitty : le fichier doit être accessible en lecture et en
écriture. Pour un fichier de root, utilisez `sudo -e` depuis le shell.
- La suppression d'un répertoire non vide affiche une erreur, jamais une
suppression récursive.
## Configurer l'explorateur
Les réglages vivent dans `~/.config/kitty/file-manager.conf` (même syntaxe que
`kitty.conf`) :
```conf
# Afficher les fichiers cachés à l'ouverture
show_hidden yes
# name (défaut) ou mtime (plus récent d'abord)
sort_by mtime
# Remplacer un raccourci
map toggle_hidden ctrl+h toggle_hidden
map delete x delete
```
Actions disponibles : `quit`, `move_up`, `move_down`, `page_up`, `page_down`,
`home`, `end`, `activate`, `enter_dir`, `parent_dir`, `cd_here`,
`toggle_hidden`, `create_file`, `create_dir`, `rename`, `delete`, `copy_path`,
`refresh`.
L'éditeur est celui de kitty : l'option `editor` de `kitty.conf`, ou `VISUAL`
puis `EDITOR` quand elle vaut `.` (le défaut). Pour forcer nano, mettez
`editor nano` dans `kitty.conf`, pas dans `file-manager.conf`.
## Tester et vérifier
```sh
./test.py # suite complète (Python + Go)
./test.py --module kittens/file_manager # tests Go du panneau
./test.py TestTruncateToWidth # un test Go nommé
./test.py type-check # vérification de types
ruff check --fix # lint Python
```
Sans passer par `test.py`, les tests Go du panneau se lancent directement :
```sh
go test ./kittens/file_manager/
```
Après une modification du Go ou du Python du kitten, `./dev.sh build` est
obligatoire : c'est lui qui régénère `cli_generated.go` / `conf_generated.go`
et réinstalle les modules Python du panneau.
## Construire la documentation
La documentation HTML et les pages de manuel demandent Sphinx :
```sh
./dev.sh deps --for-docs
./dev.sh docs
```
La page `docs/kittens/file-manager.rst` est incluse par le motif `kittens/*` du
sommaire (`docs/kittens_intro.rst`) et embarque les options générées.
## Paquet Arch
```sh
cd packaging
makepkg -f # -s pour installer les dépendances manquantes
```
Le résultat est `fws-kitty-<version>-<rel>-<arch>.pkg.tar.zst`. Le paquet
s'appelle `fws-kitty`, remplace `kitty` via `provides`/`conflicts` et installe
les binaires dans `/usr/bin`.
```sh
sudo pacman -U fws-kitty-*.pkg.tar.zst
kitty --version
kitten --version
kitten file-manager --help
```
`makepkg` construit depuis la branche `_branch` du `PKGBUILD` (`main` par
défaut). Pour empaqueter cette branche avant fusion, modifiez la ligne en haut
du fichier (une variable d'environnement ne suffit pas, le `PKGBUILD`
réaffecte `_branch`) :
```sh
_branch=feat/file-manager-panel
```
La publication dans un dépôt pacman (`repo-add`, configuration client,
automatisation) est détaillée dans `packaging/README.md`.
## Dépannage
| Symptôme | Cause et solution |
| --- | --- |
| `fork/exec .../dependencies/linux-amd64/bin/python: no such file or directory` | Bundle de dépendances incomplet. `build` le détecte maintenant et relance `deps` ; sinon `rm -rf dependencies && ./dev.sh deps`. |
| `undefined: create_cmd`, `undefined: Options`, `undefined: NewConfig` | Code Go généré absent (fichiers ignorés par git). Lancer `./dev.sh build`, pas `go build ./...`. |
| `Unknown kitten: file-manager` ou l'aide ne le liste pas | Binaire `kitten` obsolète : relancer `./dev.sh build` et utiliser `kitty/launcher/kitten`. |
| `+file-manager is not a known kitten` | Le panneau s'appelle `kitten file-manager` (sans `+`). |
| `kitten: command not found` | Les binaires sont dans `kitty/launcher/` : chemin complet, `PATH` ou lien symbolique. |
| Le panneau se ferme sans changer de répertoire | Lancé dans un dock : `cd` n'a pas de shell cible. Utiliser `Ctrl+Entrée` depuis une fenêtre de shell. |
| `... is not readable and writeable` en ouvrant un fichier | L'édition passe par kitty et demande un accès en lecture et écriture. Ouvrir le fichier avec `sudo -e` depuis le shell. |
| Rien ne s'affiche / pas de fenêtre | Pas de serveur graphique : session X11/Wayland, WSLg, ou socket monté dans Docker. |
| `X11/extensions/XInput2.h: No such file` | Installer `libxi` (XInput2). |
| `dev.sh: $'\r': command not found` | Fins de ligne CRLF, voir « Récupérer le code ». |
| Compilation très lente sous Windows | Montage Docker depuis `C:` : préférer un Arch natif, WSL2 ou un volume local. |
| `error: failed to init transaction (unable to lock database)` avec `makepkg -s` | Un autre pacman tourne, ou utilisez `makepkg -f --nodeps` avec les dépendances déjà installées. |
### Vérifier que la branche est complète
```sh
git status --short # doit être vide (ou seulement des artefacts ignorés)
git ls-files packaging # doit lister PKGBUILD et README.md
./dev.sh build
./test.py --module kittens/file_manager
./kitty/launcher/kitten file-manager --help
```
`packaging/` est actuellement **non versionné** : tant qu'il n'est pas commité
et poussé, un `git pull` sur une autre machine ne le récupère pas.
## Organisation du dépôt
| Dossier | Contenu |
| --- | --- |
| `kitty/` | Cœur du terminal (C, Python) |
| `kittens/` | Kittens intégrés, dont `file_manager/` |
| `tools/` | Outils Go (`kitten`, `kitty`, complétion) |
| `glfw/`, `glad/`, `3rdparty/` | Fenêtrage et dépendances embarquées |
| `docs/` | Documentation Sphinx (FR) |
| `gen/`, `bypy/` | Génération de code et scripts de build |
| `packaging/` | Paquet Arch |
| `kitty_tests/` | Tests Python |
Licence : GPL-3.0-only (`LICENSE`).
+18 -4
View File
@@ -367,6 +367,18 @@ func prepend(env_var, path string) {
os.Setenv(env_var, path+val)
}
func python_exe() string {
switch runtime.GOOS {
case "linux":
return filepath.Join(root_dir(), "bin", "python")
case `darwin`:
return filepath.Join(root_dir(), macos_python)
default:
exit("Building is only supported on Linux and macOS")
}
return ""
}
func setup_to_run_python() (python string) {
root := root_dir()
for _, x := range os.Environ() {
@@ -379,18 +391,20 @@ func setup_to_run_python() (python string) {
case "linux":
prepend("LD_LIBRARY_PATH", filepath.Join(root, "lib"))
os.Setenv("PYTHONHOME", root)
python = filepath.Join(root, "bin", "python")
case `darwin`:
python = filepath.Join(root, macos_python)
default:
exit("Building is only supported on Linux and macOS")
}
return
return python_exe()
}
func build(args []string) {
chdir_to_base()
if _, err := os.Stat(folder); err != nil {
// Check the Python binary instead of the dependencies folder: the folder
// survives a git pull (it is gitignored, so a clone has none) but can
// contain only the cached tarball, which used to fail later with a
// cryptic missing Python error instead of downloading the bundle.
if _, err := os.Stat(python_exe()); err != nil {
dependencies(nil)
}
root := root_dir()
+18 -24
View File
@@ -17,7 +17,7 @@ perdre l'environnement, l'historique ni l'état de la session.
Lancer le panneau avec :code:`kitten file-manager`, ou depuis une
:ref:`fenêtre dockée <docks>` pour l'avoir en permanence à côté du shell::
map ctrl+shift+e launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager --open-here
map ctrl+shift+e launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager
Il peut aussi tourner dans un :doc:`panneau du bureau </kittens/panel>` ou dans
n'importe quelle :term:`fenêtre kitty <window>` classique.
@@ -32,11 +32,10 @@ est passé en argument ou avec ``--start-dir``.
donc pas le répertoire du shell : utilisez :kbd:`Ctrl+Entrée` dans une
fenêtre de shell.
Les actions qui ferment le panneau (:kbd:`Entrée` et :kbd:`Ctrl+Entrée`) ne
peuvent agir que sur la fenêtre qui l'a lancé : dans un dock, elles ferment
le panneau sans effet. Pour ouvrir des fichiers depuis un dock, lancez le
panneau avec ``--open-here`` : il ouvre alors l'éditeur dans sa propre
fenêtre et reprend la main une fois l'éditeur fermé.
L'ouverture d'un fichier, elle, fonctionne partout : le panneau confie le
fichier à kitty, qui lance l'éditeur dans un nouvel onglet. Le fichier
dispose ainsi de toute la fenêtre même depuis un dock, et le panneau reprend
la main à la fermeture de l'éditeur, avec la même sélection.
Actions
@@ -45,13 +44,15 @@ Actions
:kbd:`Entrée`
Si la sélection est un répertoire, il devient le répertoire courant du
shell et le panneau se ferme. Si c'est un fichier, il est ouvert dans
l'éditeur configuré (:opt:`editor`, :envvar:`VISUAL` ou :envvar:`EDITOR`).
Avec l'option ``open_with_sudo``, l'éditeur est lancé via :code:`sudo` pour
pouvoir modifier les fichiers appartenant à root.
l'éditeur de kitty (:opt:`editor`, :envvar:`VISUAL` ou :envvar:`EDITOR`)
dans un nouvel onglet ; le panneau reste ouvert et retrouve sa sélection
lorsque l'éditeur se ferme.
Avec ``--open-here``, l'éditeur est lancé dans la fenêtre du panneau et le
panneau reprend la main après sa fermeture, au lieu de rendre la commande au
shell. C'est ce mode qu'il faut utiliser dans un dock.
Le nouvel onglet est ce qui donne au fichier toute la fenêtre : dans un
dock, exécuter l'éditeur dans le panneau le réduirait à la largeur du dock.
L'édition passe par le protocole d'édition de kitty, le fichier doit donc
être accessible en lecture et en écriture ; pour un fichier de root,
utilisez :code:`sudo -e` depuis le shell.
:kbd:`→` ou :kbd:`L`
descend dans le répertoire sélectionné sans toucher au shell.
@@ -98,10 +99,6 @@ personnalisation::
# ~/.config/kitty/file-manager.conf
show_hidden yes
sort_by mtime
# Éditeur utilisé avec --open-here
editor nano
# Ouvrir les fichiers avec sudo (utile pour les fichiers de root)
open_with_sudo yes
map quit esc quit
map toggle_hidden ctrl+h toggle_hidden
map delete x delete
@@ -116,14 +113,11 @@ Deux réglages d'apparence sont aussi disponibles : ``show_hidden`` affiche les
entrées cachées à l'ouverture du panneau et ``sort_by`` vaut ``name`` (tri par
nom en ignorant la casse) ou ``mtime`` (tri par date de dernière modification).
``editor`` choisit l'éditeur utilisé en mode ``--open-here``, par exemple
``editor nano`` ou ``editor "code -w"``. Laissé vide, le panneau utilise
:envvar:`VISUAL`, puis :envvar:`EDITOR`, puis :code:`vi`.
``open_with_sudo`` préfixe la commande d'édition par :code:`sudo`, ce qui
permet d'ouvrir un fichier que l'utilisateur ne peut pas modifier, comme un
fichier de configuration système. Le mot de passe, s'il est demandé, se saisit
dans le shell qui héberge le panneau.
L'éditeur n'est pas choisi par le panneau : le fichier est confié à kitty, qui
utilise son option :opt:`editor` de :file:`kitty.conf`. Quand celle-ci vaut
:code:`.` (le défaut), :envvar:`VISUAL` puis :envvar:`EDITOR` sont utilisés,
avec repli sur le premier éditeur connu installé. Pour forcer nano, ajoutez
:code:`editor nano` dans :file:`kitty.conf`.
.. include:: /generated/conf-kitten-file_manager.rst
+24 -50
View File
@@ -16,7 +16,6 @@ import (
"github.com/kovidgoyal/kitty/tools/config"
"github.com/kovidgoyal/kitty/tools/tui"
"github.com/kovidgoyal/kitty/tools/tui/loop"
"github.com/kovidgoyal/kitty/tools/utils/shlex"
"github.com/kovidgoyal/kitty/tools/wcswidth"
)
@@ -203,7 +202,6 @@ type Handler struct {
message string
result_action string
result_path string
open_here bool
shortcut_tracker config.ShortcutTracker
keyboard_shortcuts []*config.KeyAction
}
@@ -398,7 +396,7 @@ func (h *Handler) copy_selected_path() {
}
// activate implements the primary action: the selected directory becomes the
// working directory of the shell, the selected file is opened by the host.
// working directory of the shell, the selected file is opened in the editor.
func (h *Handler) activate() {
e, ok := h.selected_entry()
if !ok {
@@ -410,46 +408,28 @@ func (h *Handler) activate() {
h.change_shell_dir_to(path)
return
}
if h.open_here {
h.open_file_in_panel(path)
h.open_file(path)
}
// edit_args is the client side of kitty's edit protocol. The terminal opens the
// editor in a new tab, which gives the file a whole window even when the panel
// is docked. The tab closes when the editor exits and the panel is redrawn in
// place, instead of handing the command to the shell and disappearing.
func edit_args(path string) []string {
return []string{"edit-in-kitty", "--type=tab", path}
}
func (h *Handler) open_file(path string) {
exe, err := os.Executable()
if err != nil {
h.message = err.Error()
h.draw_screen()
return
}
h.result_action, h.result_path = "open", path
h.lp.Quit(0)
}
// editor_cmd resolves the editor used by --open-here. The panel's own `editor`
// option comes first because kitty's `editor` option is not visible to a
// process started with launch, then the usual environment variables.
func editor_cmd(conf *Config) []string {
for _, candidate := range []string{conf.Editor, os.Getenv("VISUAL"), os.Getenv("EDITOR")} {
if candidate == "" {
continue
}
if words, err := shlex.Split(candidate); err == nil && len(words) > 0 {
return words
}
}
return []string{"vi"}
}
// open_cmdline builds the command that opens path in the editor.
func open_cmdline(conf *Config, path string) []string {
cmdline := append(editor_cmd(conf), path)
if conf.Open_with_sudo {
// -- stops sudo from eating editor arguments that look like its own options.
cmdline = append([]string{"sudo", "--"}, cmdline...)
}
return cmdline
}
// open_file_in_panel runs the editor in the panel's own window. A docked panel
// has to do this itself: kitty never sends the result of a launch --type=window-dock
// back to the shell, so the panel would otherwise close without opening anything.
func (h *Handler) open_file_in_panel(path string) {
cmdline := open_cmdline(h.conf, path)
err := h.lp.SuspendAndRun(func() error {
cmd := exec.Command(cmdline[0], cmdline[1:]...)
// The loop must give up the tty while edit-in-kitty talks to the terminal,
// otherwise both processes compete for input and escape code responses.
err = h.lp.SuspendAndRun(func() error {
cmd := exec.Command(exe, edit_args(path)...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
return cmd.Run()
})
@@ -791,15 +771,9 @@ func (h *Handler) draw_screen() {
}
}
// result_payload is the JSON data handed over to the Python result handler. The
// sudo flag travels with the result so that handle_result does not have to read
// file-manager.conf a second time.
// result_payload is the JSON data handed over to the Python result handler.
func (h *Handler) result_payload() map[string]string {
data := map[string]string{"action": h.result_action, "path": h.result_path}
if h.result_action == "open" && h.conf.Open_with_sudo {
data["sudo"] = "1"
}
return data
return map[string]string{"action": h.result_action, "path": h.result_path}
}
func load_config(opts *Options) (*Config, error) {
@@ -828,7 +802,7 @@ func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) {
if err != nil {
return 1, err
}
h := &Handler{lp: lp, conf: conf, cwd: start_dir, show_hidden: opts.ShowHidden || conf.Show_hidden, open_here: opts.OpenHere}
h := &Handler{lp: lp, conf: conf, cwd: start_dir, show_hidden: opts.ShowHidden || conf.Show_hidden}
h.keyboard_shortcuts = config.ResolveShortcuts(conf.KeyboardShortcuts)
lp.MouseTrackingMode(loop.FULL_MOUSE_TRACKING)
+15 -37
View File
@@ -53,11 +53,10 @@ opt(
'editor',
'',
long_text="""
Command used to open a file when the panel opens it itself, that is when
:code:`--open-here` is given. When empty, :envvar:`VISUAL` then
:envvar:`EDITOR` are used, falling back to :code:`vi`. kitty's own :opt:`editor`
option is not visible to a panel started with :code:`launch`, so set this option
when the panel runs in a dock and the two differ.
Deprecated and ignored. Files are opened through kitty's edit protocol, so the
editor is the :opt:`editor` option of :file:`kitty.conf`, with :envvar:`VISUAL`
then :envvar:`EDITOR` used when it is :code:`.` (the default). The option is
still accepted so that existing configuration files keep loading.
""",
)
@@ -66,9 +65,9 @@ opt(
'no',
option_type='to_bool',
long_text="""
Prefix the editor command with :code:`sudo` when opening a file, so that files
the user cannot write to, such as system configuration files, can still be
edited. The password prompt, if any, appears in the shell that hosts the panel.
Deprecated and ignored. kitty's edit protocol sends the file back when the
editor exits and therefore needs a file the user can write to. Open privileged
files with :code:`sudo -e` from the shell instead.
""",
)
@@ -95,11 +94,10 @@ map(
'activate enter activate',
long_text="""
When the selection is a directory it becomes the working directory of the shell
that launched the panel. When it is a file, the shell receives the command that
opens it in the editor configured with the :opt:`editor` option,
:envvar:`VISUAL` or :envvar:`EDITOR`. With :code:`--open-here` the panel runs the
editor in its own window instead, which is what makes this action work in a
docked panel.
that launched the panel. When it is a file, the panel opens it in kitty's editor
(:opt:`editor`, :envvar:`VISUAL` or :envvar:`EDITOR`) in a new tab, and is
drawn again with the same selection once the editor exits. The new tab is what
gives the file a whole window even when the panel runs in a dock.
""",
)
map(
@@ -154,9 +152,8 @@ Show hidden files when the panel opens.
--open-here
type=bool-set
Open files in the panel's own window instead of sending the editor command to
the shell. Required in a window dock, where kitty never hands the result back to
the shell.
Deprecated and ignored. Files are always opened in a new tab, so this flag is
only accepted so that existing mappings keep working.
--config -c
@@ -190,37 +187,18 @@ def change_directory(w: Any, path: str) -> None:
w.paste_text(cmd)
def open_file(w: Any, path: str, use_sudo: bool = False) -> None:
# Run the editor in the shell that hosted the panel, like the cd action, so
# the file opens where the user already is instead of in a new tab.
from kitty.utils import get_editor
cmd = get_editor(path_to_edit=path)
if use_sudo:
# -- stops sudo from eating editor arguments that look like its own options.
cmd = ['sudo', '--'] + cmd
text = shlex.join(cmd)
if w.at_prompt:
w.write_to_child(text + '\r')
else:
w.paste_text(text)
@result_handler(has_ready_notification=True)
def handle_result(args: list[str], data: dict[str, Any], target_window_id: int, boss: BossType) -> None:
if not data:
return
action, path = data.get('action'), data.get('path')
if not action or not path:
if action != 'cd' or not path:
return
w = boss.window_id_map.get(target_window_id)
if w is None:
boss.ring_bell_if_allowed()
return
if action == 'cd':
change_directory(w, path)
elif action == 'open':
open_file(w, path, data.get('sudo') == '1')
change_directory(w, path)
help_text = 'Browse directories in a side panel and change the working directory of the shell without leaving it'
+11 -49
View File
@@ -180,37 +180,9 @@ func TestOpenWithSudoOption(t *testing.T) {
}
}
func TestEditorCommand(t *testing.T) {
t.Setenv("VISUAL", "")
t.Setenv("EDITOR", "")
if got := editor_cmd(NewConfig()); len(got) != 1 || got[0] != "vi" {
t.Fatalf("expected the vi fallback, got %#v", got)
}
t.Setenv("EDITOR", "nano")
if got := editor_cmd(NewConfig()); len(got) != 1 || got[0] != "nano" {
t.Fatalf("EDITOR must be used when the option is empty, got %#v", got)
}
t.Setenv("VISUAL", "code -w")
if got := editor_cmd(NewConfig()); len(got) != 2 || got[0] != "code" || got[1] != "-w" {
t.Fatalf("VISUAL must win over EDITOR, got %#v", got)
}
conf := NewConfig()
conf.Editor = "micro --wrap"
if got := editor_cmd(conf); len(got) != 2 || got[0] != "micro" || got[1] != "--wrap" {
t.Fatalf("the editor option must win over the environment, got %#v", got)
}
}
func TestOpenCmdline(t *testing.T) {
conf := NewConfig()
conf.Editor = "nano"
got := open_cmdline(conf, "/tmp/a.py")
if len(got) != 2 || got[0] != "nano" || got[1] != "/tmp/a.py" {
t.Fatalf("unexpected command line: %#v", got)
}
conf.Open_with_sudo = true
got = open_cmdline(conf, "/tmp/a.py")
want := []string{"sudo", "--", "nano", "/tmp/a.py"}
func TestEditArgs(t *testing.T) {
got := edit_args("/tmp/a.py")
want := []string{"edit-in-kitty", "--type=tab", "/tmp/a.py"}
if len(got) != len(want) {
t.Fatalf("expected %#v, got %#v", want, got)
}
@@ -222,32 +194,22 @@ func TestOpenCmdline(t *testing.T) {
}
func TestLoadConfigReadsOpenWithSudo(t *testing.T) {
// The option is ignored now, but old configuration files must keep loading.
dir := t.TempDir()
path := filepath.Join(dir, "file-manager.conf")
if err := os.WriteFile(path, []byte("open_with_sudo yes\n"), 0o644); err != nil {
if err := os.WriteFile(path, []byte("open_with_sudo yes\neditor nano\n"), 0o644); err != nil {
t.Fatal(err)
}
conf, err := load_config(&Options{Config: []string{path}})
if err != nil {
if _, err := load_config(&Options{Config: []string{path}}); err != nil {
t.Fatal(err)
}
if !conf.Open_with_sudo {
t.Fatal("open_with_sudo yes in file-manager.conf must enable sudo")
}
}
func TestResultPayloadCarriesSudoOnlyWhenOpening(t *testing.T) {
h := &Handler{conf: NewConfig(), result_action: "open", result_path: "/tmp/a.py"}
if _, ok := h.result_payload()["sudo"]; ok {
t.Fatal("sudo must not be requested when the option is disabled")
}
h.conf.Open_with_sudo = true
if got := h.result_payload()["sudo"]; got != "1" {
t.Fatalf("sudo must be requested when opening a file, got %q", got)
}
h.result_action = "cd"
if _, ok := h.result_payload()["sudo"]; ok {
t.Fatal("changing directory must never ask for sudo")
func TestResultPayload(t *testing.T) {
h := &Handler{result_action: "cd", result_path: "/tmp"}
got := h.result_payload()
if len(got) != 2 || got["action"] != "cd" || got["path"] != "/tmp" {
t.Fatalf("unexpected payload: %#v", got)
}
}
+70
View File
@@ -0,0 +1,70 @@
# Maintainer: FWS <maintainers@nocode-var.tech>
#
# Arch package for the FWS kitty fork. Built with makepkg from this directory:
#
# cd packaging && makepkg -f
#
# The resulting fws-kitty-<version>-<rel>-<arch>.pkg.tar.zst is ready to be
# added to a pacman repository (see README.md in this directory).
#
# kitty installs its own binary under /usr/bin and cannot coexist with the
# upstream package, hence provides/conflicts.
pkgname=fws-kitty
pkgver=0.50.0
pkgrel=1
pkgdesc='Fast, feature-rich, GPU based terminal (FWS fork with the file-manager kitten)'
arch=('x86_64' 'aarch64')
url='https://gitea.nocode-var.tech/FWS/FWS-Kitty'
license=('GPL-3.0-only')
# Replace main with the tag or commit to ship once the release is cut.
_branch=main
_repo='https://gitea.nocode-var.tech/FWS/FWS-Kitty.git'
depends=(
python harfbuzz zlib libpng lcms2 xxhash openssl
pixman cairo freetype2 fontconfig
libx11 libxcb libxrandr libxinerama libxcursor libxi libxrender
libxkbcommon libxkbcommon-x11 mesa wayland dbus
libcanberra systemd-libs
)
makedepends=(
git go python pkgconf ncurses rsync which file simde shader-slang
)
optdepends=(
'imagemagick: display uncommon image formats'
'shader-slang: custom shaders'
)
provides=('kitty')
conflicts=('kitty')
source=(
"$pkgname::git+$_repo#branch=$_branch"
"nerdfonts-symbols.tar.xz::https://github.com/ryanoasis/nerd-fonts/releases/download/v3.5.1/NerdFontsSymbolsOnly.tar.xz"
)
sha256sums=('SKIP' '01172f37db8543edb102e5cb5c64101c9f4686630804d49b419aa07b23a69996')
prepare() {
# kitty embeds the mono variant of the Nerd font at build time, but Arch
# only packages the proportional one, so ship the font with the build.
mkdir -p "$pkgname/fonts"
cp "$srcdir/SymbolsNerdFontMono-Regular.ttf" "$pkgname/fonts/"
cd "$pkgname"
# linux-package regenerates the man pages and the HTML docs, and some of
# their dependencies (furo, sphinx-design) are not packaged for Arch, so
# keep a local throwaway environment instead of requiring the system ones.
# Do not reuse the system packages: pip would then skip installing sphinx
# itself and the venv would have no sphinx-build entry point.
python -m venv .docs-venv
.docs-venv/bin/pip install --disable-pip-version-check -q -r docs/requirements.txt
}
package() {
cd "$pkgname"
# kitty's linux-package target stages a full self-contained install, so
# pointing --prefix at the package root is enough; no manual file copying.
PATH="$srcdir/$pkgname/.docs-venv/bin:$PATH" python setup.py linux-package --prefix "$pkgdir/usr"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
+77
View File
@@ -0,0 +1,77 @@
# Paquet Arch — FWS-Kitty
Ce dossier contient le `PKGBUILD` qui produit le paquet pacman de FWS-Kitty,
prêt à être publié dans le dépôt officiel FWS. Le paquet s'appelle
`fws-kitty` et remplace `kitty` (`provides`/`conflicts`) : les deux ne peuvent
pas cohabiter, ils installent les mêmes binaires dans `/usr/bin`.
## Construire
```sh
cd packaging
makepkg -f # ajouter -s pour installer les dépendances manquantes
```
Le résultat est `fws-kitty-<version>-<rel>-<arch>.pkg.tar.zst`.
`makepkg` construit depuis la branche indiquée par `_branch` en haut du
`PKGBUILD` (`main` par défaut). Pour publier une version précise, pointez-la
sur un tag ou un commit :
```sh
_branch=v0.50.0
```
La police Symbols Nerd Font Mono n'est pas fournie par les dépôts Arch
(`ttf-nerd-fonts-symbols` n'installe que la variante proportionnelle) : le
`PKGBUILD` télécharge la release 3.5.1 de nerd-fonts et place le fichier dans
`fonts/` avant la compilation.
La cible `linux-package` de kitty reconstruit aussi les pages de manuel et la
documentation HTML : le `PKGBUILD` crée pour cela un environnement Python
isolé dans `prepare()` et installe `docs/requirements.txt` (Sphinx, thème
Furo…), car certaines de ces dépendances ne sont pas dans les dépôts Arch
(`sphinx-design`, `furo` au nom `python-sphinx-furo`).
## Tester localement
```sh
sudo pacman -U fws-kitty-*.pkg.tar.zst
kitty --version
kitten --version
```
## Publier dans le dépôt pacman
Un dépôt pacman est un simple dossier HTTP contenant les paquets et une base
`repo-add` :
```sh
repo-add fws-kitty.db.tar.gz fws-kitty-*.pkg.tar.zst
```
Puis, côté client, dans `/etc/pacman.conf` :
```ini
[fws]
SigLevel = Optional TrustAll
Server = https://<hôte>/fws/$arch
```
Le dossier doit être servi en HTTP/HTTPS statique (nginx, Caddy, GitHub/Gitea
Pages…). Gitea n'a pas de registre pacman natif : le registre « Generic »
fonctionne pour héberger les fichiers, mais pacman a besoin d'URL stables pour
`fws-kitty.db.tar.gz` et les `.pkg.tar.zst`, ce qu'un simple dossier servi par
nginx (ou des assets de release) fournit directement.
Pour une publication automatique, il suffit d'enchaîner dans la CI :
```sh
makepkg -f --nodeps # ou -s avec un utilisateur autorisé à pacman
repo-add repo/fws-kitty.db.tar.gz fws-kitty-*.pkg.tar.zst
# puis copier repo/ vers le serveur
```
Si le dépôt doit aussi fournir `kitty-terminfo` et l'intégration shell aux
serveurs SSH, ces fichiers peuvent être découpés en paquets séparés : la
documentation de kitty (`docs/build.rst`, section « Notes pour les
empaqueteurs ») décrit la répartition.