Compare commits
49
Commits
96c0e5655d
..
v0.1.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58fc9d1aa3
|
||
|
|
c1d4ca8c2d
|
||
|
|
7c17b5c0ce
|
||
|
|
f204f77b40
|
||
|
|
ab0533b825
|
||
|
|
d5f2847ff5
|
||
|
|
81df6f2d3a
|
||
|
|
45a16ea61c
|
||
|
|
8482515412
|
||
|
|
4e3d6b97dc
|
||
|
|
13c49c89aa
|
||
|
|
d373fe5df8
|
||
|
|
263607ab47
|
||
|
|
d866fae523
|
||
|
|
7839f666d5
|
||
|
|
9512d8a417
|
||
|
|
38ec8c86d7
|
||
|
|
ea4faeb5ac
|
||
|
|
1b0f5faf6a
|
||
|
|
9bacd745c2
|
||
|
|
15bab74943
|
||
|
|
44b9aa166e
|
||
|
|
665f9d5f2c
|
||
|
|
831852a89f
|
||
|
|
f74d33597e
|
||
|
|
b1b26803cc
|
||
|
|
fb19c04798
|
||
|
|
205f01673b
|
||
|
|
ef5301a0bb
|
||
|
|
a2629aa4d9
|
||
|
|
36c4221b3f
|
||
|
|
d0c014d066
|
||
|
|
9f2749c529
|
||
|
|
d91a79e361
|
||
|
|
85f481b457
|
||
|
|
49cbc34ff2
|
||
|
|
2f127f05af
|
||
|
|
98b73edbcb
|
||
|
|
f896d75211
|
||
|
|
598030025b
|
||
|
|
343c7e8aeb
|
||
|
|
b691050719
|
||
|
|
5d2e28b144
|
||
|
|
e7e4e849eb
|
||
|
|
1b330bcf81
|
||
|
|
38afa54ad9
|
||
|
|
a8129b1d5d
|
||
|
|
0a15964b3e
|
||
|
|
d6b19f026b
|
No files matched your search
@@ -0,0 +1,393 @@
|
|||||||
|
# Raccourcis clavier de FWS-Kitty
|
||||||
|
|
||||||
|
Tous les raccourcis de ce document sont **actifs par défaut** : kitty et les
|
||||||
|
fonctions ajoutées par FWS s'utilisent au lancement sans écrire une seule ligne
|
||||||
|
de configuration. Le fichier couvre les raccourcis globaux du terminal, ceux des
|
||||||
|
fonctions FWS (gestionnaire de fichiers, historique du presse-papiers,
|
||||||
|
restauration de session) et les touches des interfaces intégrées (kittens).
|
||||||
|
|
||||||
|
Les tableaux reflètent les valeurs de `kitty/options/definition.py`. La palette
|
||||||
|
de commandes (`Ctrl+Shift+F3`) liste en direct toutes les actions, leur touche
|
||||||
|
et leur catégorie, y compris les actions sans raccourci.
|
||||||
|
|
||||||
|
> **Aide rapide** : `Ctrl+Shift+H` (`kitty_mod+H`) ouvre le panneau latéral qui
|
||||||
|
> liste tous les raccourcis, avec recherche et catégories. Dans le shell kitty,
|
||||||
|
> `help` fait la même chose.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
| Notation | Signification |
|
||||||
|
| --- | --- |
|
||||||
|
| `kitty_mod` | Alias de `Ctrl+Shift` sous Linux, BSD et macOS, redéfinissable avec l'option `kitty_mod`. |
|
||||||
|
| `Ctrl+Shift+X` | Maintenir `Ctrl` et `Shift`, puis appuyer sur `X`. |
|
||||||
|
| `Ctrl+Shift+P` puis `F` | Séquence : relâcher la première combinaison avant de presser `F`. |
|
||||||
|
| `→`, `←`, `↑`, `↓` | Flèches de direction. |
|
||||||
|
| `Entrée`, `Échap`, `Retour arrière`, `Suppr` | Touches `Enter`, `Escape`, `Backspace`, `Delete`. |
|
||||||
|
| `Page↑`, `Page↓`, `Début`, `Fin` | Touches `Page Up`, `Page Down`, `Home`, `End`. |
|
||||||
|
| `KP+`, `KP-` | Touches `+` et `-` du pavé numérique. |
|
||||||
|
|
||||||
|
`kitty_mod` vaut `Ctrl+Shift` sur toutes les plateformes : `kitty_mod+c` se lit
|
||||||
|
`Ctrl+Shift+C`, même sous macOS. Les raccourcis macOS habituels (`Cmd+C`,
|
||||||
|
`Cmd+V`, `Cmd+T`…) sont des mappings distincts, regroupés plus bas.
|
||||||
|
|
||||||
|
## Fonctions ajoutées par FWS
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+E` | Ouvre le gestionnaire de fichiers dans un dock à gauche de la fenêtre. La touche est la même sous macOS. |
|
||||||
|
| `Ctrl+Shift+Alt+V` (`kitty_mod+alt+v`) | Colle une entrée de l'historique du presse-papiers. |
|
||||||
|
| `Ctrl+Shift+Alt+F` (`kitty_mod+alt+f`) | Demande une recherche floue, puis colle l'entrée choisie. |
|
||||||
|
| `Ctrl+Shift+Alt+R` (`kitty_mod+alt+r`) | Restaure la session enregistrée à la dernière fermeture de kitty. |
|
||||||
|
| `Ctrl+Shift+H` (`kitty_mod+H`) | Ouvre le panneau latéral de tous les raccourcis. |
|
||||||
|
|
||||||
|
Deux fonctions FWS ne demandent aucune touche :
|
||||||
|
|
||||||
|
- Les **notifications de fin de commande** sont actives avec
|
||||||
|
`notify_on_cmd_finish unfocused` : une commande de plus de 5 secondes notifie
|
||||||
|
quand la fenêtre n'est plus au premier plan, avec sa durée et son code de
|
||||||
|
sortie.
|
||||||
|
- La **barre d'onglets** affiche le code de sortie des commandes en échec
|
||||||
|
(`✘ code`), le répertoire courant abrégé et les boutons `×` (fermer l'onglet)
|
||||||
|
et `+` (nouvel onglet). Elle est visible dès le premier onglet.
|
||||||
|
|
||||||
|
> `Ctrl+Shift+E` ouvrait auparavant les URLs visibles (`open_url`). Le
|
||||||
|
> gestionnaire de fichiers prend la touche par défaut. Pour retrouver l'ancien
|
||||||
|
> comportement, ajoutez `map ctrl+shift+e open_url_with_hints` dans
|
||||||
|
> `kitty.conf` ; le panneau reste accessible avec `kitten file-manager`.
|
||||||
|
|
||||||
|
## Presse-papiers
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+C` | Copie la sélection dans le presse-papiers. |
|
||||||
|
| `Ctrl+Shift+V` | Colle le presse-papiers. |
|
||||||
|
| `Ctrl+Shift+S` | Colle la sélection primaire. |
|
||||||
|
| `Maj+Inser` | Colle la sélection primaire. |
|
||||||
|
| `Ctrl+Shift+Alt+V` | Colle une entrée de l'historique. |
|
||||||
|
| `Ctrl+Shift+Alt+F` | Recherche dans l'historique puis colle. |
|
||||||
|
| `Ctrl+Shift+O` | Passe la sélection à un programme (navigateur par défaut sans argument). |
|
||||||
|
|
||||||
|
## Défilement et historique
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+↑` ou `Ctrl+Shift+K` | Défile d'une ligne vers le haut. |
|
||||||
|
| `Ctrl+Shift+↓` ou `Ctrl+Shift+J` | Défile d'une ligne vers le bas. |
|
||||||
|
| `Ctrl+Shift+Page↑` | Défile d'une page vers le haut. |
|
||||||
|
| `Ctrl+Shift+Page↓` | Défile d'une page vers le bas. |
|
||||||
|
| `Ctrl+Shift+Début` | Va au début de l'historique. |
|
||||||
|
| `Ctrl+Shift+Fin` | Va à la fin de l'historique. |
|
||||||
|
| `Ctrl+Shift+Z` | Va au prompt précédent. |
|
||||||
|
| `Ctrl+Shift+X` | Va au prompt suivant. |
|
||||||
|
| `Ctrl+Shift+H` | Affiche tout l'historique dans un pager. |
|
||||||
|
| `Ctrl+Shift+G` | Affiche la sortie de la dernière commande dans un pager. |
|
||||||
|
| `Ctrl+Shift+/` | Recherche dans l'historique. |
|
||||||
|
|
||||||
|
## Fenêtres
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+Entrée` | Nouvelle fenêtre dans l'onglet courant. |
|
||||||
|
| `Ctrl+Shift+N` | Nouvelle fenêtre du système (OS Window). |
|
||||||
|
| `Ctrl+Shift+W` | Ferme la fenêtre courante. |
|
||||||
|
| `Ctrl+Shift+]` | Fenêtre suivante. |
|
||||||
|
| `Ctrl+Shift+[` | Fenêtre précédente. |
|
||||||
|
| `Ctrl+Shift+F` | Avance la fenêtre dans la disposition. |
|
||||||
|
| `Ctrl+Shift+B` | Recule la fenêtre dans la disposition. |
|
||||||
|
| ``Ctrl+Shift+` `` | Place la fenêtre au premier plan de la disposition. |
|
||||||
|
| `Ctrl+Shift+R` | Démarre le redimensionnement au clavier. |
|
||||||
|
| `Ctrl+Shift+1` … `Ctrl+Shift+0` | Active la 1re … 10e fenêtre. |
|
||||||
|
| `Ctrl+Shift+F7` | Active la fenêtre visible sous le pointeur. |
|
||||||
|
| `Ctrl+Shift+F8` | Échange la fenêtre courante avec celle sous le pointeur. |
|
||||||
|
|
||||||
|
## Onglets
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+→` | Onglet suivant. |
|
||||||
|
| `Ctrl+Shift+←` | Onglet précédent. |
|
||||||
|
| `Ctrl+Tab` / `Ctrl+Shift+Tab` | Onglet suivant / précédent. |
|
||||||
|
| `Ctrl+Shift+T` | Nouvel onglet. |
|
||||||
|
| `Ctrl+Shift+Q` | Ferme l'onglet courant. |
|
||||||
|
| `Ctrl+Shift+.` | Déplace l'onglet vers la droite. |
|
||||||
|
| `Ctrl+Shift+,` | Déplace l'onglet vers la gauche. |
|
||||||
|
| `Ctrl+Shift+Alt+T` | Renomme l'onglet courant. |
|
||||||
|
| `Ctrl+Shift+F11` | Bascule le plein écran. |
|
||||||
|
| `Ctrl+Shift+F10` | Bascule la maximisation. |
|
||||||
|
|
||||||
|
## Dispositions
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+L` | Passe à la disposition suivante. |
|
||||||
|
|
||||||
|
## Taille de police
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+=`, `Ctrl+Shift++` ou `Ctrl+Shift+KP+` | Agrandit la police de 2 points. |
|
||||||
|
| `Ctrl+Shift+-` ou `Ctrl+Shift+KP-` | Réduit la police de 2 points. |
|
||||||
|
| `Ctrl+Shift+Retour arrière` | Rétablit la taille configurée. |
|
||||||
|
|
||||||
|
## Sélectionner du texte (hints)
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+P` puis `F` | Insère le chemin sélectionné dans la ligne de commande. |
|
||||||
|
| `Ctrl+Shift+P` puis `Maj+F` | Ouvre le chemin sélectionné. |
|
||||||
|
| `Ctrl+Shift+P` puis `C` | Choisit un fichier et l'insère. |
|
||||||
|
| `Ctrl+Shift+P` puis `D` | Choisit un répertoire et l'insère. |
|
||||||
|
| `Ctrl+Shift+P` puis `L` | Insère la ligne sélectionnée. |
|
||||||
|
| `Ctrl+Shift+P` puis `W` | Insère le mot sélectionné. |
|
||||||
|
| `Ctrl+Shift+P` puis `H` | Insère le hash (commit git) sélectionné. |
|
||||||
|
| `Ctrl+Shift+P` puis `N` | Ouvre le fichier à la ligne indiquée (`fichier:42`). |
|
||||||
|
| `Ctrl+Shift+P` puis `Y` | Ouvre le lien hypertexte sélectionné. |
|
||||||
|
|
||||||
|
Dans une sélection par hints, tapez l'étiquette affichée sur le texte visé ;
|
||||||
|
`Entrée` ou `Espace` valide une étiquette vide lorsque les hints utilisent
|
||||||
|
plusieurs lettres.
|
||||||
|
|
||||||
|
## Sessions
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+Alt+R` | Restaure les onglets, dispositions, répertoires et titres de la dernière session. |
|
||||||
|
|
||||||
|
La même restauration est disponible au démarrage :
|
||||||
|
|
||||||
|
```sh
|
||||||
|
kitty --session=last
|
||||||
|
```
|
||||||
|
|
||||||
|
`save_as_session`, `goto_session` et `close_session` n'ont pas de touche par
|
||||||
|
défaut : lancez-les depuis la palette de commandes (`Ctrl+Shift+F3`) ou
|
||||||
|
associez-les dans `kitty.conf`.
|
||||||
|
|
||||||
|
## Divers
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Ctrl+Shift+F1` | Ouvre la documentation de kitty. |
|
||||||
|
| `Ctrl+Shift+F3` | Ouvre la palette de commandes. |
|
||||||
|
| `Ctrl+Shift+E` | Ouvre le gestionnaire de fichiers (FWS). |
|
||||||
|
| `Ctrl+Shift+F2` | Ouvre `kitty.conf` dans l'éditeur. |
|
||||||
|
| `Ctrl+Shift+F5` | Recharge la configuration. |
|
||||||
|
| `Ctrl+Shift+F6` | Affiche la configuration effective. |
|
||||||
|
| `Ctrl+Shift+U` | Saisie de caractères Unicode. |
|
||||||
|
| `Ctrl+Shift+Échap` | Ouvre un shell kitty (contrôle à distance). |
|
||||||
|
| `Ctrl+Shift+A` puis `M` | Augmente l'opacité du fond. |
|
||||||
|
| `Ctrl+Shift+A` puis `L` | Diminue l'opacité du fond. |
|
||||||
|
| `Ctrl+Shift+A` puis `1` | Fond totalement opaque. |
|
||||||
|
| `Ctrl+Shift+A` puis `D` | Rétablit l'opacité configurée. |
|
||||||
|
| `Ctrl+Shift+Suppr` | Réinitialise le terminal. |
|
||||||
|
| `Ctrl+Shift+Alt+H` | Envoie `Hello World` au terminal (exemple fourni par kitty). |
|
||||||
|
|
||||||
|
## Raccourcis macOS
|
||||||
|
|
||||||
|
Sous macOS, les raccourcis par défaut de kitty sont majoritairement en `Cmd`,
|
||||||
|
tandis que les raccourcis FWS basés sur `kitty_mod` restent en `Ctrl+Shift`.
|
||||||
|
Les entrées suivantes complètent les tableaux précédents.
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Cmd+C` | Copie, ou transmet `Ctrl+C` au programme s'il n'y a pas de sélection. |
|
||||||
|
| `Cmd+V` | Colle le presse-papiers. |
|
||||||
|
| `Cmd+↑` / `Cmd+↓` | Défile d'une ligne vers le haut / le bas. |
|
||||||
|
| `Cmd+Page↑` / `Cmd+Page↓` | Défile d'une page vers le haut / le bas. |
|
||||||
|
| `Cmd+Début` / `Cmd+Fin` | Début / fin de l'historique. |
|
||||||
|
| `Cmd+F` | Recherche dans l'historique. |
|
||||||
|
| `Cmd+Entrée` | Nouvelle fenêtre. |
|
||||||
|
| `Cmd+N` | Nouvelle fenêtre du système. |
|
||||||
|
| `Cmd+W` | Ferme l'onglet ; `Cmd+Shift+W` ferme la fenêtre du système. |
|
||||||
|
| `Cmd+T` | Nouvel onglet. |
|
||||||
|
| `Cmd+Shift+]` / `Cmd+Shift+[` | Onglet suivant / précédent. |
|
||||||
|
| `Cmd+Shift+I` | Renomme l'onglet. |
|
||||||
|
| `Cmd+1` … `Cmd+9` | Active la 1re … 9e fenêtre. |
|
||||||
|
| `Cmd+R` | Redimensionnement au clavier. |
|
||||||
|
| ``Cmd+` `` / ``Cmd+Shift+` `` | Fenêtre du système suivante / précédente. |
|
||||||
|
| `Cmd++`, `Cmd+=`, `Cmd+Shift+=` | Agrandit la police. |
|
||||||
|
| `Cmd+-`, `Cmd+Shift+-` | Réduit la police. |
|
||||||
|
| `Cmd+0` | Rétablit la taille de police. |
|
||||||
|
| `Cmd+,` | Ouvre `kitty.conf`. |
|
||||||
|
| `Ctrl+Cmd+,` | Recharge la configuration. |
|
||||||
|
| `Alt+Cmd+,` | Affiche la configuration effective. |
|
||||||
|
| `Alt+Cmd+R` | Réinitialise le terminal. |
|
||||||
|
| `Ctrl+Cmd+F` | Bascule le plein écran. |
|
||||||
|
| `Ctrl+Cmd+Espace` | Saisie Unicode. |
|
||||||
|
| `Cmd+K` | Efface l'écran jusqu'au curseur. |
|
||||||
|
| `Alt+Cmd+K` | Efface l'historique. |
|
||||||
|
| `Cmd+L` | Efface la dernière commande. |
|
||||||
|
| `Ctrl+Cmd+L` | Efface l'écran et l'historique. |
|
||||||
|
| `Alt+Cmd+S` | Active la saisie clavier sécurisée. |
|
||||||
|
| `Cmd+Shift+/` | Ouvre le site de kitty. |
|
||||||
|
| `Cmd+H` / `Alt+Cmd+H` | Masque kitty / les autres applications. |
|
||||||
|
| `Cmd+M` | Réduit la fenêtre. |
|
||||||
|
| `Cmd+Q` | Quitte kitty. |
|
||||||
|
|
||||||
|
## Barre d'onglets et souris
|
||||||
|
|
||||||
|
| Geste | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| Clic gauche sur un onglet | Active l'onglet. |
|
||||||
|
| Clic sur `×` | Ferme l'onglet. |
|
||||||
|
| Clic sur `+` | Ouvre un nouvel onglet. |
|
||||||
|
| Clic du milieu sur un onglet | Ferme l'onglet. |
|
||||||
|
| Glisser un onglet | Réordonne, détache ou déplace l'onglet. |
|
||||||
|
| Clic gauche dans le gestionnaire de fichiers | Sélectionne l'entrée. |
|
||||||
|
|
||||||
|
## Gestionnaire de fichiers (`Ctrl+Shift+E`)
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Entrée` | Entre dans le répertoire sélectionné, ou ouvre le fichier dans l'éditeur dans un nouvel onglet. |
|
||||||
|
| `→` ou `L` | Entre dans le répertoire sélectionné sans toucher au shell. |
|
||||||
|
| `←`, `Retour arrière` ou `H` | Remonte au répertoire parent. |
|
||||||
|
| `Ctrl+Entrée` ou `C` | Déplace le shell vers le répertoire affiché puis ferme le panneau. |
|
||||||
|
| `↑` ou `K` | Sélection précédente. |
|
||||||
|
| `↓` ou `J` | Sélection suivante. |
|
||||||
|
| `Tab` / `Maj+Tab` | Sélection suivante / précédente. |
|
||||||
|
| `Page↑` ou `Ctrl+B` | Sélection précédente d'une page. |
|
||||||
|
| `Page↓` ou `Ctrl+F` | Sélection suivante d'une page. |
|
||||||
|
| `Début` ou `G` | Première entrée. |
|
||||||
|
| `Fin` ou `Maj+G` | Dernière entrée. |
|
||||||
|
| `/` | Filtre la liste par recherche floue ; `Entrée` ouvre la sélection, `Échap` efface la requête. |
|
||||||
|
| `:` | Ouvre la palette des actions du panneau ; `Entrée` exécute l'action. |
|
||||||
|
| `O` | Ouvre le fichier sélectionné dans un nouvel onglet. |
|
||||||
|
| `T` | Ouvre le fichier sélectionné dans une nouvelle fenêtre du système. |
|
||||||
|
| `N` | Crée un fichier. |
|
||||||
|
| `Maj+N` ou `A` | Crée un répertoire. |
|
||||||
|
| `R` | Renomme l'entrée sélectionnée. |
|
||||||
|
| `D` | Supprime l'entrée 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` ou `Q` | Ferme le panneau sans changer de répertoire. |
|
||||||
|
|
||||||
|
Toutes ces touches se redéfinissent dans `~/.config/kitty/file-manager.conf`
|
||||||
|
avec la syntaxe `map <touche> <action>`.
|
||||||
|
|
||||||
|
## Palette de commandes (`Ctrl+Shift+F3`)
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| Texte | Filtre les résultats. |
|
||||||
|
| `Entrée` | Exécute l'action sélectionnée. |
|
||||||
|
| `Échap` | Efface la requête, ou ferme la palette si elle est vide. |
|
||||||
|
| `↑`, `Maj+Tab`, `Ctrl+K` ou `Ctrl+P` | Sélection précédente. |
|
||||||
|
| `↓`, `Tab`, `Ctrl+J` ou `Ctrl+N` | Sélection suivante. |
|
||||||
|
| `Page↑` / `Page↓` | Sélection précédente / suivante d'une page. |
|
||||||
|
| `Début` / `Fin` | Premier / dernier résultat. |
|
||||||
|
| `Retour arrière` | Efface le dernier caractère de la requête. |
|
||||||
|
| `F12` | Affiche ou masque les actions sans raccourci. |
|
||||||
|
|
||||||
|
## Panneau d'aide (`help`)
|
||||||
|
|
||||||
|
Dans le shell kitty (`Ctrl+Shift+Échap`), `help` sans argument ouvre un panneau
|
||||||
|
latéral qui liste tous les raccourcis actifs, classés par catégorie, avec une
|
||||||
|
recherche rapide. Depuis un terminal : `kitty +kitten help` ; le raccourci
|
||||||
|
par défaut `Ctrl+Shift+H` (`kitty_mod+H`) ouvre le même panneau.
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| Texte | Filtre les raccourcis. |
|
||||||
|
| `Échap` | Efface la requête, puis ferme le panneau. |
|
||||||
|
| `↑` / `↓`, `Ctrl+K` / `Ctrl+J` | Raccourci précédent / suivant. |
|
||||||
|
| `Tab` / `Maj+Tab` | Raccourci suivant / précédent. |
|
||||||
|
| `Page↑` / `Page↓` | Défile d'une page. |
|
||||||
|
| `Début` / `Fin` | Premier / dernier raccourci. |
|
||||||
|
| `F12` | Affiche ou masque les actions sans raccourci. |
|
||||||
|
| `Entrée` | Sans effet : le panneau est en lecture seule. |
|
||||||
|
|
||||||
|
## Historique du presse-papiers (`Ctrl+Shift+Alt+V`)
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| Numéro affiché devant une entrée | Colle immédiatement cette entrée. |
|
||||||
|
| `Échap` | Ferme la liste sans rien coller. |
|
||||||
|
|
||||||
|
`Ctrl+Shift+Alt+F` commence par demander une requête floue, puis affiche la
|
||||||
|
même liste. L'historique vit en mémoire uniquement : il disparaît à la
|
||||||
|
fermeture de kitty et les copies marquées privées n'y sont jamais enregistrées.
|
||||||
|
|
||||||
|
## Saisie Unicode (`Ctrl+Shift+U`)
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `F1` … `F4` ou `Ctrl+1` … `Ctrl+4` | Change de mode. |
|
||||||
|
| `Ctrl+[` / `Ctrl+]` ou `Ctrl+Tab` / `Ctrl+Shift+Tab` | Change de mode. |
|
||||||
|
| `Entrée` | Insère le caractère dont le code hexadécimal est saisi. |
|
||||||
|
| `↑` / `↓` | Caractère récent précédent / suivant. |
|
||||||
|
| `.` puis index à deux chiffres | Choisit un caractère récent. |
|
||||||
|
| Flèches ou `Tab` | Sélectionne un caractère parmi les correspondances du mode Nom. |
|
||||||
|
| `Espace` puis `.` et l'index | Sélectionne une correspondance sans les flèches. |
|
||||||
|
|
||||||
|
## Hints
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| Étiquette affichée | Sélectionne le texte marqué. |
|
||||||
|
| `Entrée` ou `Espace` | Valide une étiquette vide quand plusieurs lettres sont nécessaires. |
|
||||||
|
| Clic sur le texte marqué | Sélectionne sans taper l'étiquette. |
|
||||||
|
|
||||||
|
## Diff (`kitten diff`)
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| `Q` | Quitte. |
|
||||||
|
| `K` / `↑`, `J` / `↓` | Défile d'une ligne. |
|
||||||
|
| `Page↑` / `Page↓` | Défile d'une page. |
|
||||||
|
| `Début` / `Fin` | Haut / bas du fichier. |
|
||||||
|
| `Espace` ou `Ctrl+F`, `Ctrl+B` | Page suivante / précédente. |
|
||||||
|
| `Ctrl+D` / `Ctrl+U` | Demi-page vers le bas / le haut. |
|
||||||
|
| `N` / `P` | Modification suivante / précédente. |
|
||||||
|
| `+` / `-` | Augmente / réduit le contexte. |
|
||||||
|
| `A` | Affiche toutes les lignes de contexte. |
|
||||||
|
| `=` | Rétablit le contexte par défaut. |
|
||||||
|
| `/` / `?` | Recherche vers l'avant / l'arrière. |
|
||||||
|
| `Échap` | Efface la recherche ou quitte. |
|
||||||
|
| `>` ou `.`, `<` ou `,` | Correspondance suivante / précédente. |
|
||||||
|
| `Y` | Copie la sélection. |
|
||||||
|
| `Ctrl+C` | Copie la sélection ou quitte. |
|
||||||
|
|
||||||
|
## Choix de fichiers (`kitten choose-files`)
|
||||||
|
|
||||||
|
| Touche | Action |
|
||||||
|
| --- | --- |
|
||||||
|
| Texte | Filtre la liste. |
|
||||||
|
| `Entrée` | Choisit le fichier sélectionné. |
|
||||||
|
| `Tab` | Entre dans le répertoire sélectionné. |
|
||||||
|
| `Maj+Tab` | Remonte d'un répertoire. |
|
||||||
|
| `Ctrl+Entrée` | Choisit le répertoire courant (ou saisit un nom de fichier en mode sauvegarde). |
|
||||||
|
| `Alt+Entrée` | Modifie le nom du fichier sélectionné. |
|
||||||
|
| `Maj+Entrée` | Ajoute ou retire le fichier de la sélection multiple. |
|
||||||
|
| `Ctrl+clic` / `Alt+clic` | Ajoute un fichier / sélectionne une plage à la souris. |
|
||||||
|
|
||||||
|
Les raccourcis de cette interface se redéfinissent dans
|
||||||
|
`~/.config/kitty/choose-files.conf`.
|
||||||
|
|
||||||
|
## Thèmes et polices
|
||||||
|
|
||||||
|
`kitten themes` et `kitten choose-fonts` se pilotent au clavier : tapez quelques
|
||||||
|
lettres pour filtrer, `Entrée` valide la famille ou le thème, `R` affine la
|
||||||
|
police régulière dans `choose-fonts`. Le détail figure dans leurs pages de
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
## Personnaliser un raccourci
|
||||||
|
|
||||||
|
Les raccourcis globaux se redéfinissent dans `~/.config/kitty/kitty.conf` :
|
||||||
|
|
||||||
|
```conf
|
||||||
|
# Remplacer l'ouverture du gestionnaire de fichiers
|
||||||
|
map ctrl+shift+e launch --type=overlay kitten file-manager
|
||||||
|
|
||||||
|
# Rétablir l'ouverture des URLs sur Ctrl+Shift+E
|
||||||
|
map ctrl+shift+e open_url_with_hints
|
||||||
|
|
||||||
|
# Choisir d'autres touches pour l'historique
|
||||||
|
map kitty_mod+alt+h paste_from_clipboard_history
|
||||||
|
map kitty_mod+alt+g search_clipboard_history
|
||||||
|
```
|
||||||
|
|
||||||
|
La configuration est rechargée automatiquement, ou manuellement avec
|
||||||
|
`Ctrl+Shift+F5`. Une touche peut aussi être retirée en la mappant sur rien :
|
||||||
|
`map ctrl+shift+e`.
|
||||||
@@ -9,7 +9,8 @@ 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,
|
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.
|
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
|
`DEV.md` reste le guide de développement condensé, `README.asciidoc` est le
|
||||||
README d'origine de kitty.
|
README d'origine de kitty et `RACCOURCIS-CLAVIER.md` liste tous les raccourcis
|
||||||
|
actifs par défaut, sans configuration.
|
||||||
|
|
||||||
## Contenu de la branche `feat/file-manager-panel`
|
## Contenu de la branche `feat/file-manager-panel`
|
||||||
|
|
||||||
|
|||||||
@@ -244,12 +244,29 @@ Detailed list of changes
|
|||||||
automatic, and a corrupt or oversized saved state is discarded instead of
|
automatic, and a corrupt or oversized saved state is discarded instead of
|
||||||
blocking startup. See :ref:`sessions` for details.
|
blocking startup. See :ref:`sessions` for details.
|
||||||
|
|
||||||
|
- The :doc:`file manager <kittens/file-manager>` now keeps its directory in
|
||||||
|
step with the shell by default: a :code:`cd` moves the panel into the same
|
||||||
|
directory and walking through the panel moves the shell at its next prompt,
|
||||||
|
for bash, zsh and fish. Nothing is typed into the terminal, so no command
|
||||||
|
lands in the history and a multi-line command being typed is left untouched.
|
||||||
|
Set :code:`sync_cwd no` in :file:`file-manager.conf` to keep the two
|
||||||
|
directories independent, as before.
|
||||||
|
|
||||||
- :kbd:`Ctrl+Shift+E` now opens the :doc:`file manager kitten
|
- :kbd:`Ctrl+Shift+E` now opens the :doc:`file manager kitten
|
||||||
<kittens/file-manager>` in a left dock by default, instead of requiring a
|
<kittens/file-manager>` in a left dock by default, instead of requiring a
|
||||||
manual mapping. This takes the key over from :ac:`open_url`; remap
|
manual mapping. This takes the key over from :ac:`open_url`; remap
|
||||||
:kbd:`Ctrl+Shift+E` to :code:`open_url_with_hints` in :file:`kitty.conf` to
|
:kbd:`Ctrl+Shift+E` to :code:`open_url_with_hints` in :file:`kitty.conf` to
|
||||||
restore the previous behavior.
|
restore the previous behavior.
|
||||||
|
|
||||||
|
- The kitty shell now opens a searchable, categorized keyboard shortcut panel
|
||||||
|
in a side dock when :code:`help` is run without arguments, or when
|
||||||
|
:kbd:`kitty_mod+H` is pressed. The panel can also be started with
|
||||||
|
:code:`kitty +kitten help`.
|
||||||
|
|
||||||
|
- The default :opt:`tab_title_template` now shows the abbreviated working
|
||||||
|
directory of the tab before its title, so the directory indicator of the tab
|
||||||
|
bar is visible without configuration.
|
||||||
|
|
||||||
- Accessibility: :kbd:`Tab` and :kbd:`Shift+Tab` move the selection in the
|
- Accessibility: :kbd:`Tab` and :kbd:`Shift+Tab` move the selection in the
|
||||||
:doc:`file manager <kittens/file-manager>` and the
|
:doc:`file manager <kittens/file-manager>` and the
|
||||||
:doc:`command palette <kittens/command-palette>` by default. A new
|
:doc:`command palette <kittens/command-palette>` by default. A new
|
||||||
|
|||||||
+14
-1
@@ -181,11 +181,24 @@ Variables que kitty définit en lançant des programmes enfants
|
|||||||
fonctions appelant :program:`kitty` fonctionnent correctement.
|
fonctions appelant :program:`kitty` fonctionnent correctement.
|
||||||
|
|
||||||
.. envvar:: KITTY_WINDOW_ID
|
.. envvar:: KITTY_WINDOW_ID
|
||||||
|
|
||||||
Un entier qui est l'identifiant de la :term:`fenêtre <window>` kitty dans
|
Un entier qui est l'identifiant de la :term:`fenêtre <window>` kitty dans
|
||||||
laquelle le programme s'exécute. Utilisable avec la :doc:`facilité de
|
laquelle le programme s'exécute. Utilisable avec la :doc:`facilité de
|
||||||
contrôle à distance de kitty <remote-control>`.
|
contrôle à distance de kitty <remote-control>`.
|
||||||
|
|
||||||
|
.. envvar:: KITTY_CWD_SYNC_DIR
|
||||||
|
|
||||||
|
Le répertoire de session dans lequel les shells et les kittens qui coopèrent
|
||||||
|
échangent leur répertoire courant, voir la :ref:`synchronisation du
|
||||||
|
gestionnaire de fichiers <file_manager>`. Il n'est lisible que par votre
|
||||||
|
utilisateur et disparaît à la fin de la session.
|
||||||
|
|
||||||
|
.. envvar:: KITTY_SPECIAL_WINDOW_PARENT
|
||||||
|
|
||||||
|
Un entier qui est l'identifiant de la :term:`fenêtre <window>` pour laquelle
|
||||||
|
une fenêtre spéciale (overlay ou dock) a été ouverte. Absent des fenêtres
|
||||||
|
normales ; le :doc:`gestionnaire de fichiers </kittens/file-manager>` s'en
|
||||||
|
sert pour retrouver le shell dont il suit le répertoire.
|
||||||
|
|
||||||
.. envvar:: KITTY_PID
|
.. envvar:: KITTY_PID
|
||||||
|
|
||||||
Un entier qui est l'identifiant du processus kitty dans lequel le programme
|
Un entier qui est l'identifiant du processus kitty dans lequel le programme
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ est passé en argument ou avec ``--start-dir``.
|
|||||||
panneau a été lancé. Lancé dans un dock ou un panneau du bureau, il ne change
|
panneau a été lancé. Lancé dans un dock ou un panneau du bureau, il ne change
|
||||||
donc pas le répertoire du shell : :kbd:`Ctrl+Entrée` ferme le panneau sans
|
donc pas le répertoire du shell : :kbd:`Ctrl+Entrée` ferme le panneau sans
|
||||||
déplacer le shell. Lancez le panneau depuis une fenêtre de shell pour changer
|
déplacer le shell. Lancez le panneau depuis une fenêtre de shell pour changer
|
||||||
de répertoire.
|
de répertoire, sauf si la synchronisation décrite plus bas est activée : le
|
||||||
|
dock suit alors la fenêtre active du groupe au moment de sa création.
|
||||||
|
|
||||||
L'ouverture d'un fichier, elle, fonctionne partout : le panneau confie le
|
L'ouverture d'un fichier, elle, fonctionne partout : le panneau confie le
|
||||||
fichier à kitty, qui lance l'éditeur dans un nouvel onglet. Le fichier
|
fichier à kitty, qui lance l'éditeur dans un nouvel onglet. Le fichier
|
||||||
@@ -59,7 +60,8 @@ Actions
|
|||||||
utilisez :code:`sudo -e` depuis le shell.
|
utilisez :code:`sudo -e` depuis le shell.
|
||||||
|
|
||||||
:kbd:`→` ou :kbd:`L`
|
:kbd:`→` ou :kbd:`L`
|
||||||
descend dans le répertoire sélectionné sans toucher au shell.
|
descend dans le répertoire sélectionné ; le shell y va aussi, au prompt
|
||||||
|
suivant, quand la synchronisation est active.
|
||||||
|
|
||||||
:kbd:`←`, :kbd:`Retour arrière` ou :kbd:`H`
|
:kbd:`←`, :kbd:`Retour arrière` ou :kbd:`H`
|
||||||
remonte au répertoire parent.
|
remonte au répertoire parent.
|
||||||
@@ -111,7 +113,49 @@ Actions
|
|||||||
affiche ou masque les entrées cachées.
|
affiche ou masque les entrées cachées.
|
||||||
|
|
||||||
:kbd:`Échap` ou :kbd:`Q`
|
:kbd:`Échap` ou :kbd:`Q`
|
||||||
ferme le panneau sans rien changer.
|
ferme le panneau sans rien changer : une demande de synchronisation que le
|
||||||
|
shell n'a pas encore lue est retirée, il reste donc où il était.
|
||||||
|
|
||||||
|
|
||||||
|
Synchronisation avec le shell
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Le panneau et le shell partagent leur répertoire courant depuis la version
|
||||||
|
0.50.1, dans les deux sens : un :code:`cd` dans le shell amène le panneau dans
|
||||||
|
le même répertoire, et chaque répertoire ouvert dans le panneau devient aussi
|
||||||
|
celui du shell, sans même avoir à valider. Pour que chacun garde son propre
|
||||||
|
répertoire, alors que le panneau part toujours de celui du shell et n'en change
|
||||||
|
plus ::
|
||||||
|
|
||||||
|
# ~/.config/kitty/file-manager.conf
|
||||||
|
sync_cwd no
|
||||||
|
|
||||||
|
L'échange ne passe pas par le terminal. kitty exporte un répertoire de session
|
||||||
|
dans :envvar:`KITTY_CWD_SYNC_DIR` ; le shell y publie son répertoire courant et
|
||||||
|
le panneau y dépose celui qu'il veut. Le panneau retrouve le shell qui l'a lancé
|
||||||
|
grâce à :envvar:`KITTY_SPECIAL_WINDOW_PARENT`. L'intégration shell de kitty, pour
|
||||||
|
bash, zsh et fish, applique la demande avec :code:`builtin cd` : aucune commande
|
||||||
|
n'entre dans l'historique et une commande multi-lignes en cours de saisie n'est
|
||||||
|
pas soumise.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
La synchronisation demande l'intégration shell de kitty, active par défaut
|
||||||
|
pour bash, zsh et fish. Les autres shells gardent le comportement précédent :
|
||||||
|
le panneau retape la commande :code:`cd` dans le terminal, comme lorsque
|
||||||
|
l'option est désactivée.
|
||||||
|
|
||||||
|
Le changement est appliqué au prompt suivant : le shell se déplace quand la
|
||||||
|
commande suivante démarre, ou qu'une ligne vide est validée, et non pendant
|
||||||
|
que vous parcourez le panneau. C'est le prix à payer pour ne jamais écrire
|
||||||
|
dans le terminal. Si vous quittez le panneau avec :kbd:`Échap` avant que le
|
||||||
|
shell ait lu la demande, elle est retirée et le shell ne bouge pas.
|
||||||
|
|
||||||
|
Lancé dans un dock, le panneau suit la fenêtre active du groupe au moment où
|
||||||
|
le dock est créé. Si vous passez ensuite à une autre fenêtre du même groupe,
|
||||||
|
il continue de suivre cette première fenêtre : relancez le dock pour changer
|
||||||
|
de cible. Dans un panneau du bureau, il n'y a pas de shell à suivre et la
|
||||||
|
synchronisation reste inerte.
|
||||||
|
|
||||||
|
|
||||||
.. _file-manager-shortcuts:
|
.. _file-manager-shortcuts:
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
Panneau d'aide aux raccourcis
|
||||||
|
=============================
|
||||||
|
|
||||||
|
.. program:: kitty +kitten help
|
||||||
|
|
||||||
|
Le panneau d'aide affiche tous les raccourcis clavier actifs, triés par
|
||||||
|
catégorie, avec une recherche rapide. Il s'ouvre dans un dock latéral, comme le
|
||||||
|
gestionnaire de fichiers, et reste en lecture seule : :kbd:`Entrée` ne déclenche
|
||||||
|
aucune action. Il est mappé sur :kbd:`kitty_mod+H` (:kbd:`Ctrl+Shift+H` par
|
||||||
|
défaut).
|
||||||
|
|
||||||
|
Utilisation
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Dans le :doc:`shell kitty </shell>` (:kbd:`Ctrl+Shift+Échap`), la commande
|
||||||
|
``help`` sans argument ouvre le panneau, tout comme :kbd:`kitty_mod+H` dans
|
||||||
|
n'importe quelle fenêtre ::
|
||||||
|
|
||||||
|
help
|
||||||
|
|
||||||
|
Depuis un terminal, lancez le kitten directement ::
|
||||||
|
|
||||||
|
kitty +kitten help
|
||||||
|
|
||||||
|
Pour l'ouvrir dans un dock depuis un raccourci de ``kitty.conf`` ::
|
||||||
|
|
||||||
|
map kitty_mod+f4 launch --type=window-dock --dock-edge=left --dock-size=60 kitty +kitten help
|
||||||
|
|
||||||
|
Commandes
|
||||||
|
---------
|
||||||
|
|
||||||
|
.. table::
|
||||||
|
|
||||||
|
===================== ===================================================
|
||||||
|
Touche Action
|
||||||
|
===================== ===================================================
|
||||||
|
Texte Filtre les raccourcis (recherche floue).
|
||||||
|
:kbd:`Entrée` Sans effet : le panneau est une référence.
|
||||||
|
:kbd:`Échap` Efface la requête, puis ferme le panneau.
|
||||||
|
:kbd:`↑`, :kbd:`↓` Sélectionne le raccourci précédent ou suivant.
|
||||||
|
:kbd:`Tab` Sélectionne le raccourci suivant.
|
||||||
|
:kbd:`Shift+Tab` Sélectionne le raccourci précédent.
|
||||||
|
:kbd:`Ctrl+K` Sélectionne le raccourci précédent.
|
||||||
|
:kbd:`Ctrl+J` Sélectionne le raccourci suivant.
|
||||||
|
:kbd:`Page↑` Défile d'une page vers le haut.
|
||||||
|
:kbd:`Page↓` Défile d'une page vers le bas.
|
||||||
|
:kbd:`Début` Premier raccourci.
|
||||||
|
:kbd:`Fin` Dernier raccourci.
|
||||||
|
:kbd:`F12` Affiche ou masque les actions sans raccourci.
|
||||||
|
===================== ===================================================
|
||||||
|
|
||||||
|
Les raccourcis affichés proviennent de la configuration effective de kitty :
|
||||||
|
les remappages de ``kitty.conf`` sont donc visibles. Les actions sans raccourci
|
||||||
|
sont masquées par défaut ; :kbd:`F12` les affiche.
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
kittens/choose-fonts
|
kittens/choose-fonts
|
||||||
kittens/hints
|
kittens/hints
|
||||||
kittens/command-palette
|
kittens/command-palette
|
||||||
|
kittens/help
|
||||||
kittens/quick-access-terminal
|
kittens/quick-access-terminal
|
||||||
kittens/choose-files
|
kittens/choose-files
|
||||||
kittens/dnd
|
kittens/dnd
|
||||||
@@ -66,6 +67,11 @@ et à créer des programmes autonomes utiles. Quelques kittens importants :
|
|||||||
depuis une seule surcouche de recherche.
|
depuis une seule surcouche de recherche.
|
||||||
|
|
||||||
|
|
||||||
|
:doc:`Aide aux raccourcis <kittens/help>`
|
||||||
|
Consultez tous les raccourcis clavier dans un panneau latéral, avec une
|
||||||
|
recherche rapide et un classement par catégorie.
|
||||||
|
|
||||||
|
|
||||||
:doc:`Terminal à accès rapide <kittens/quick-access-terminal>`
|
:doc:`Terminal à accès rapide <kittens/quick-access-terminal>`
|
||||||
Accédez à une fenêtre kitty flottante et semi-transparente d'accès rapide
|
Accédez à une fenêtre kitty flottante et semi-transparente d'accès rapide
|
||||||
avec une seule combinaison de touches.
|
avec une seule combinaison de touches.
|
||||||
|
|||||||
@@ -275,6 +275,8 @@ type Handler struct {
|
|||||||
cv *utils.CachedValues[*CachedSettings]
|
cv *utils.CachedValues[*CachedSettings]
|
||||||
shortcut_tracker config.ShortcutTracker
|
shortcut_tracker config.ShortcutTracker
|
||||||
keyboard_shortcuts []*config.KeyAction
|
keyboard_shortcuts []*config.KeyAction
|
||||||
|
read_only bool
|
||||||
|
data_file string
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize sets up the TUI: screen size, cursor, cached settings, and initial data load.
|
// initialize sets up the TUI: screen size, cursor, cached settings, and initial data load.
|
||||||
@@ -287,17 +289,30 @@ func (h *Handler) initialize() (string, error) {
|
|||||||
h.lp.SetCursorVisible(true)
|
h.lp.SetCursorVisible(true)
|
||||||
h.lp.SetCursorShape(loop.BAR_CURSOR, true)
|
h.lp.SetCursorShape(loop.BAR_CURSOR, true)
|
||||||
h.lp.AllowLineWrapping(false)
|
h.lp.AllowLineWrapping(false)
|
||||||
h.lp.SetWindowTitle("Command Palette")
|
title := "Command Palette"
|
||||||
|
if h.read_only {
|
||||||
|
title = "Keyboard shortcuts"
|
||||||
|
}
|
||||||
|
h.lp.SetWindowTitle(title)
|
||||||
|
|
||||||
|
if h.read_only {
|
||||||
|
// A reference panel is about bindings, not about actions without one.
|
||||||
|
h.show_unmapped = false
|
||||||
|
} else {
|
||||||
// Initialize with ShowUnmapped: true as the default; Load() returns this
|
// Initialize with ShowUnmapped: true as the default; Load() returns this
|
||||||
// default when no cache file exists yet.
|
// default when no cache file exists yet.
|
||||||
h.cv = utils.NewCachedValues("command-palette", &CachedSettings{ShowUnmapped: true})
|
h.cv = utils.NewCachedValues("command-palette", &CachedSettings{ShowUnmapped: true})
|
||||||
settings := h.cv.Load()
|
settings := h.cv.Load()
|
||||||
h.show_unmapped = settings.ShowUnmapped
|
h.show_unmapped = settings.ShowUnmapped
|
||||||
|
}
|
||||||
|
|
||||||
h.keyboard_shortcuts = config.ResolveShortcuts(NewConfig().KeyboardShortcuts)
|
h.keyboard_shortcuts = config.ResolveShortcuts(NewConfig().KeyboardShortcuts)
|
||||||
|
|
||||||
if err := h.loadData(); err != nil {
|
if h.data_file != "" {
|
||||||
|
if err := h.loadDataFile(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
} else if err := h.loadData(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,8 +328,23 @@ func (h *Handler) loadData() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read stdin: %w", err)
|
return fmt.Errorf("failed to read stdin: %w", err)
|
||||||
}
|
}
|
||||||
|
return h.parseData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// loadDataFile reads the JSON produced by the help kitten and removes it so
|
||||||
|
// that repeated launches do not leave temporary files behind.
|
||||||
|
func (h *Handler) loadDataFile() error {
|
||||||
|
data, err := os.ReadFile(h.data_file)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to read keybinding data: %w", err)
|
||||||
|
}
|
||||||
|
_ = os.Remove(h.data_file)
|
||||||
|
return h.parseData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handler) parseData(data []byte) error {
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return fmt.Errorf("no input data received on stdin; this kitten must be launched from kitty")
|
return fmt.Errorf("no keybinding data received")
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(data, &h.input_data); err != nil {
|
if err := json.Unmarshal(data, &h.input_data); err != nil {
|
||||||
return fmt.Errorf("failed to parse input data: %w", err)
|
return fmt.Errorf("failed to parse input data: %w", err)
|
||||||
@@ -584,8 +614,11 @@ func (h *Handler) draw_screen() {
|
|||||||
if h.show_unmapped {
|
if h.show_unmapped {
|
||||||
unmappedToggleLabel = "Hide"
|
unmappedToggleLabel = "Hide"
|
||||||
}
|
}
|
||||||
footer := h.lp.SprintStyled("fg=bright-yellow", "[Enter]") + " Run " +
|
footer := ""
|
||||||
h.lp.SprintStyled("fg=bright-yellow", "[Esc]") + " Quit " +
|
if !h.read_only {
|
||||||
|
footer = h.lp.SprintStyled("fg=bright-yellow", "[Enter]") + " Run "
|
||||||
|
}
|
||||||
|
footer += h.lp.SprintStyled("fg=bright-yellow", "[Esc]") + " Quit " +
|
||||||
h.lp.SprintStyled("fg=bright-yellow", "\u2191\u2193") + " Navigate " +
|
h.lp.SprintStyled("fg=bright-yellow", "\u2191\u2193") + " Navigate " +
|
||||||
h.lp.SprintStyled("fg=bright-yellow", "[F12]") + " " + unmappedToggleLabel + " unmapped"
|
h.lp.SprintStyled("fg=bright-yellow", "[F12]") + " " + unmappedToggleLabel + " unmapped"
|
||||||
matchCount := ""
|
matchCount := ""
|
||||||
@@ -1005,6 +1038,10 @@ func (h *Handler) moveSelection(delta int) {
|
|||||||
|
|
||||||
// triggerSelected sets the selected binding's definition as the result and exits.
|
// triggerSelected sets the selected binding's definition as the result and exits.
|
||||||
func (h *Handler) triggerSelected() {
|
func (h *Handler) triggerSelected() {
|
||||||
|
if h.read_only {
|
||||||
|
h.lp.Beep()
|
||||||
|
return
|
||||||
|
}
|
||||||
b := h.selectedBinding()
|
b := h.selectedBinding()
|
||||||
if b == nil || b.IsMouse {
|
if b == nil || b.IsMouse {
|
||||||
h.lp.Beep()
|
h.lp.Beep()
|
||||||
@@ -1016,7 +1053,7 @@ func (h *Handler) triggerSelected() {
|
|||||||
|
|
||||||
// main runs the command palette TUI as a kitty overlay.
|
// main runs the command palette TUI as a kitty overlay.
|
||||||
func main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) {
|
func main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) {
|
||||||
if tty.IsTerminal(os.Stdin.Fd()) {
|
if opts.DataFile == "" && tty.IsTerminal(os.Stdin.Fd()) {
|
||||||
return 1, fmt.Errorf("This kitten must only be run via the command_palette action mapped to a shortcut in kitty.conf")
|
return 1, fmt.Errorf("This kitten must only be run via the command_palette action mapped to a shortcut in kitty.conf")
|
||||||
}
|
}
|
||||||
output := tui.KittenOutputSerializer()
|
output := tui.KittenOutputSerializer()
|
||||||
@@ -1025,7 +1062,7 @@ func main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) {
|
|||||||
return 1, err
|
return 1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
handler := &Handler{lp: lp}
|
handler := &Handler{lp: lp, read_only: opts.ReadOnly, data_file: opts.DataFile}
|
||||||
lp.MouseTrackingMode(loop.FULL_MOUSE_TRACKING)
|
lp.MouseTrackingMode(loop.FULL_MOUSE_TRACKING)
|
||||||
|
|
||||||
lp.OnInitialize = func() (string, error) {
|
lp.OnInitialize = func() (string, error) {
|
||||||
|
|||||||
@@ -338,6 +338,15 @@ def handle_result(args: list[str], data: dict[str, Any], target_window_id: int,
|
|||||||
help_text = 'Browse and trigger keyboard shortcuts and actions'
|
help_text = 'Browse and trigger keyboard shortcuts and actions'
|
||||||
usage = ''
|
usage = ''
|
||||||
OPTIONS = r"""
|
OPTIONS = r"""
|
||||||
|
--data-file
|
||||||
|
Read keybinding data from this JSON file instead of STDIN. Used by the
|
||||||
|
keyboard shortcuts help panel, so that it can run in a dock window.
|
||||||
|
|
||||||
|
|
||||||
|
--read-only
|
||||||
|
type=bool-set
|
||||||
|
Display the bindings without running the selected action on Enter. The panel
|
||||||
|
is then a reference, not a launcher.
|
||||||
""".format
|
""".format
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,26 @@ func (b *testHandlerBuilder) build() *Handler {
|
|||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseData(t *testing.T) {
|
||||||
|
h := &Handler{}
|
||||||
|
data := []byte(`{"modes":{"":{"Cat":[{"key":"a","action":"x","action_display":"x","definition":"x"}]}},"mouse":[],"mode_order":[""],"category_order":{"":["Cat"]}}`)
|
||||||
|
if err := h.parseData(data); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(h.all_items) != 1 {
|
||||||
|
t.Fatalf("expected 1 item, got %d", len(h.all_items))
|
||||||
|
}
|
||||||
|
if b := h.all_items[0].binding; b.Key != "a" || b.Category != "Cat" {
|
||||||
|
t.Fatalf("unexpected binding: %+v", b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseDataRejectsEmptyInput(t *testing.T) {
|
||||||
|
if err := (&Handler{}).parseData(nil); err == nil {
|
||||||
|
t.Fatal("expected an error for empty data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func newTestHandler() *Handler {
|
func newTestHandler() *Handler {
|
||||||
return newBuilder().
|
return newBuilder().
|
||||||
addBinding("", "Copy/paste", testBinding("ctrl+shift+c", "copy_to_clipboard", "Copy the selected text from the active window to the clipboard")).
|
addBinding("", "Copy/paste", testBinding("ctrl+shift+c", "copy_to_clipboard", "Copy the selected text from the active window to the clipboard")).
|
||||||
|
|||||||
@@ -221,6 +221,9 @@ type Handler struct {
|
|||||||
result_path string
|
result_path string
|
||||||
shortcut_tracker config.ShortcutTracker
|
shortcut_tracker config.ShortcutTracker
|
||||||
keyboard_shortcuts []*config.KeyAction
|
keyboard_shortcuts []*config.KeyAction
|
||||||
|
sync *shell_sync
|
||||||
|
sync_handled bool
|
||||||
|
sync_published bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) initialize() (string, error) {
|
func (h *Handler) initialize() (string, error) {
|
||||||
@@ -235,11 +238,69 @@ func (h *Handler) initialize() (string, error) {
|
|||||||
if err = h.load(h.cwd); err != nil {
|
if err = h.load(h.cwd); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
if h.sync != nil {
|
||||||
|
// Adopt the directory the shell is already in as the reference point so
|
||||||
|
// that an explicit --start-dir is not overridden by the first tick.
|
||||||
|
h.sync.last = h.sync.shell_cwd()
|
||||||
|
if _, err = h.lp.AddTimer(400*time.Millisecond, true, func(loop.IdType) error {
|
||||||
|
h.follow_shell_cwd()
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
h.draw_screen()
|
h.draw_screen()
|
||||||
h.lp.SendOverlayReady()
|
h.lp.SendOverlayReady()
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// publish_browse hands the directory the user just opened in the panel to the
|
||||||
|
// shell, so that walking through the tree in the panel walks the shell through
|
||||||
|
// it too. The shell reads the request at its next prompt; until then the panel
|
||||||
|
// remembers it so that quitting can withdraw it.
|
||||||
|
func (h *Handler) publish_browse() {
|
||||||
|
if h.sync == nil || !h.sync.shell_has_hook() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := h.sync.publish_request(h.cwd); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.sync_published = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// withdraw_sync_request drops a request published by browsing, so that leaving
|
||||||
|
// the panel without validating a directory leaves the shell where it was. It
|
||||||
|
// does nothing once the shell has read the request, which it only does at a
|
||||||
|
// prompt.
|
||||||
|
func (h *Handler) withdraw_sync_request() {
|
||||||
|
if !h.sync_published {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.sync.withdraw_request()
|
||||||
|
h.sync_published = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// follow_shell_cwd mirrors a cd made in the shell into the panel, keeping the
|
||||||
|
// selection on the same name so that the cursor does not jump around.
|
||||||
|
func (h *Handler) follow_shell_cwd() {
|
||||||
|
if h.sync == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dir := h.sync.new_target(h.cwd)
|
||||||
|
if dir == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
name := ""
|
||||||
|
if e, ok := h.selected_entry(); ok {
|
||||||
|
name = e.Name
|
||||||
|
}
|
||||||
|
if err := h.load(dir); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.select_name(name)
|
||||||
|
h.draw_screen()
|
||||||
|
}
|
||||||
|
|
||||||
// load reads dir and adopts it as the current directory. Selection is clamped
|
// load reads dir and adopts it as the current directory. Selection is clamped
|
||||||
// rather than reset so that reloading a directory after an action keeps the
|
// rather than reset so that reloading a directory after an action keeps the
|
||||||
// cursor near where it was.
|
// cursor near where it was.
|
||||||
@@ -309,6 +370,7 @@ func (h *Handler) change_dir(dir string) {
|
|||||||
}
|
}
|
||||||
h.selected, h.scroll, h.message = 0, 0, ""
|
h.selected, h.scroll, h.message = 0, 0, ""
|
||||||
h.draw_screen()
|
h.draw_screen()
|
||||||
|
h.publish_browse()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) move_selection(delta int) {
|
func (h *Handler) move_selection(delta int) {
|
||||||
@@ -483,8 +545,8 @@ func (h *Handler) open_file_in(path, window_type string) {
|
|||||||
h.draw_screen()
|
h.draw_screen()
|
||||||
}
|
}
|
||||||
|
|
||||||
// enter_dir browses into the selected directory inside the panel, leaving the
|
// enter_dir browses into the selected directory inside the panel and hands it to
|
||||||
// working directory of the shell untouched.
|
// the shell, so that both stay on the same directory.
|
||||||
func (h *Handler) enter_dir() {
|
func (h *Handler) enter_dir() {
|
||||||
e, ok := h.selected_entry()
|
e, ok := h.selected_entry()
|
||||||
if !ok || !e.IsDir {
|
if !ok || !e.IsDir {
|
||||||
@@ -496,6 +558,14 @@ func (h *Handler) enter_dir() {
|
|||||||
|
|
||||||
func (h *Handler) change_shell_dir_to(path string) {
|
func (h *Handler) change_shell_dir_to(path string) {
|
||||||
h.result_action, h.result_path = "cd", path
|
h.result_action, h.result_path = "cd", path
|
||||||
|
// With the sync on, the shell reads the request from its session file at the
|
||||||
|
// next prompt, so the handler must not also type the change into its pty.
|
||||||
|
// The request is only written once the shell proved it has the hook by
|
||||||
|
// publishing its directory: a shell without shell integration would
|
||||||
|
// otherwise never see it and the change would be silently lost.
|
||||||
|
if h.sync != nil && h.sync.shell_has_hook() && h.sync.publish_request(path) == nil {
|
||||||
|
h.sync_handled = true
|
||||||
|
}
|
||||||
h.lp.Quit(0)
|
h.lp.Quit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,7 +616,10 @@ var action_catalog = []action_info{
|
|||||||
// Actions that need the panel state are plain functions of the handler, so the
|
// Actions that need the panel state are plain functions of the handler, so the
|
||||||
// palette and the configurable shortcuts go through the same code path.
|
// palette and the configurable shortcuts go through the same code path.
|
||||||
var action_handlers = map[string]func(*Handler){
|
var action_handlers = map[string]func(*Handler){
|
||||||
"quit": func(h *Handler) { h.lp.Quit(0) },
|
"quit": func(h *Handler) {
|
||||||
|
h.withdraw_sync_request()
|
||||||
|
h.lp.Quit(0)
|
||||||
|
},
|
||||||
"move_up": func(h *Handler) { h.move_selection(-1) },
|
"move_up": func(h *Handler) { h.move_selection(-1) },
|
||||||
"move_down": func(h *Handler) { h.move_selection(1) },
|
"move_down": func(h *Handler) { h.move_selection(1) },
|
||||||
"page_up": func(h *Handler) {
|
"page_up": func(h *Handler) {
|
||||||
@@ -1136,7 +1209,11 @@ func (h *Handler) draw_screen() {
|
|||||||
|
|
||||||
// result_payload is the JSON data handed over to the Python result handler.
|
// result_payload is the JSON data handed over to the Python result handler.
|
||||||
func (h *Handler) result_payload() map[string]string {
|
func (h *Handler) result_payload() map[string]string {
|
||||||
return map[string]string{"action": h.result_action, "path": h.result_path}
|
ans := map[string]string{"action": h.result_action, "path": h.result_path}
|
||||||
|
if h.sync_handled {
|
||||||
|
ans["sync"] = "1"
|
||||||
|
}
|
||||||
|
return ans
|
||||||
}
|
}
|
||||||
|
|
||||||
func load_config(opts *Options) (*Config, error) {
|
func load_config(opts *Options) (*Config, error) {
|
||||||
@@ -1165,7 +1242,7 @@ func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 1, err
|
return 1, err
|
||||||
}
|
}
|
||||||
h := &Handler{lp: lp, conf: conf, cwd: start_dir, show_hidden: opts.ShowHidden || conf.Show_hidden}
|
h := &Handler{lp: lp, conf: conf, cwd: start_dir, show_hidden: opts.ShowHidden || conf.Show_hidden, sync: new_shell_sync_from_env(conf.Sync_cwd)}
|
||||||
h.keyboard_shortcuts = config.ResolveShortcuts(conf.KeyboardShortcuts)
|
h.keyboard_shortcuts = config.ResolveShortcuts(conf.KeyboardShortcuts)
|
||||||
lp.MouseTrackingMode(loop.FULL_MOUSE_TRACKING)
|
lp.MouseTrackingMode(loop.FULL_MOUSE_TRACKING)
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,29 @@ directories first, then files sorted by size, largest first.
|
|||||||
|
|
||||||
egr()
|
egr()
|
||||||
|
|
||||||
|
agr('shell', 'Shell synchronisation')
|
||||||
|
|
||||||
|
opt(
|
||||||
|
'sync_cwd',
|
||||||
|
'yes',
|
||||||
|
option_type='to_bool',
|
||||||
|
long_text="""
|
||||||
|
Keep the shell's working directory and the panel in step. A :code:`cd` in the
|
||||||
|
shell moves the panel to the same directory, and walking through the panel moves
|
||||||
|
the shell to the directory being browsed at its next prompt. Quitting the panel
|
||||||
|
without validating a directory withdraws a request the shell has not read yet.
|
||||||
|
|
||||||
|
The exchange goes through two small files in the session directory kitty
|
||||||
|
exports as :envvar:`KITTY_CWD_SYNC_DIR`, so nothing is typed into the shell:
|
||||||
|
the command never lands in the history and a half typed multi-line command is
|
||||||
|
left untouched. Bash, zsh and fish are supported by their kitty shell
|
||||||
|
integration; other shells keep the current behaviour. Set :code:`sync_cwd no`
|
||||||
|
to keep the two directories independent.
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
egr()
|
||||||
|
|
||||||
agr('opening', 'Opening files')
|
agr('opening', 'Opening files')
|
||||||
|
|
||||||
opt(
|
opt(
|
||||||
@@ -219,6 +242,10 @@ def handle_result(args: list[str], data: dict[str, Any], target_window_id: int,
|
|||||||
action, path = data.get('action'), data.get('path')
|
action, path = data.get('action'), data.get('path')
|
||||||
if action != 'cd' or not path:
|
if action != 'cd' or not path:
|
||||||
return
|
return
|
||||||
|
if data.get('sync'):
|
||||||
|
# The panel published the directory in the session file and the shell
|
||||||
|
# picks it up from its prompt hook, see the sync_cwd option.
|
||||||
|
return
|
||||||
w = boss.window_id_map.get(target_window_id)
|
w = boss.window_id_map.get(target_window_id)
|
||||||
if w is None:
|
if w is None:
|
||||||
boss.ring_bell_if_allowed()
|
boss.ring_bell_if_allowed()
|
||||||
|
|||||||
@@ -182,6 +182,19 @@ func TestOpenWithSudoOption(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSyncCwdIsOnByDefault(t *testing.T) {
|
||||||
|
c := NewConfig()
|
||||||
|
if !c.Sync_cwd {
|
||||||
|
t.Fatal("the panel must follow the shell by default")
|
||||||
|
}
|
||||||
|
if err := c.Parse("sync_cwd", "no"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if c.Sync_cwd {
|
||||||
|
t.Fatal("sync_cwd = no must keep the two directories independent")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestEditArgs(t *testing.T) {
|
func TestEditArgs(t *testing.T) {
|
||||||
got := edit_args("/tmp/a.py")
|
got := edit_args("/tmp/a.py")
|
||||||
want := []string{"edit-in-kitty", "--type=tab", "/tmp/a.py"}
|
want := []string{"edit-in-kitty", "--type=tab", "/tmp/a.py"}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
// License: GPLv3 Copyright: 2026, FWS
|
||||||
|
|
||||||
|
package file_manager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// shell_sync is the file based channel between a shell and the panel. kitty
|
||||||
|
// exports KITTY_CWD_SYNC_DIR to every window and KITTY_SPECIAL_WINDOW_PARENT to
|
||||||
|
// the special windows it opens for another one, so both sides agree on two file
|
||||||
|
// names without a socket or a new protocol: the shell publishes its working
|
||||||
|
// directory in <dir>/<window id>, the panel publishes the directory it wants in
|
||||||
|
// <dir>/<window id>.set. The shell applies that request from its prompt hook,
|
||||||
|
// which keeps the command out of the history and leaves a half typed multi-line
|
||||||
|
// command alone.
|
||||||
|
type shell_sync struct {
|
||||||
|
dir string
|
||||||
|
window_id string
|
||||||
|
last string
|
||||||
|
}
|
||||||
|
|
||||||
|
func new_shell_sync(dir, window_id string, enabled bool) *shell_sync {
|
||||||
|
if !enabled || dir == "" || window_id == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if info, err := os.Stat(dir); err != nil || !info.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &shell_sync{dir: dir, window_id: window_id}
|
||||||
|
}
|
||||||
|
|
||||||
|
// new_shell_sync_from_env is nil whenever the option is off or kitty did not
|
||||||
|
// give the panel a shell window to talk to, in which case the panel keeps its
|
||||||
|
// own behaviour and types the change into the shell instead.
|
||||||
|
func new_shell_sync_from_env(enabled bool) *shell_sync {
|
||||||
|
return new_shell_sync(os.Getenv("KITTY_CWD_SYNC_DIR"), os.Getenv("KITTY_SPECIAL_WINDOW_PARENT"), enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *shell_sync) shell_cwd_path() string { return filepath.Join(s.dir, s.window_id) }
|
||||||
|
func (s *shell_sync) request_path() string { return s.shell_cwd_path() + ".set" }
|
||||||
|
|
||||||
|
// shell_has_hook reports whether the shell has published its working directory
|
||||||
|
// at least once, which only the integration hook does. Without it nothing would
|
||||||
|
// consume the request, so the panel has to type the change into the shell.
|
||||||
|
func (s *shell_sync) shell_has_hook() bool {
|
||||||
|
_, err := os.Stat(s.shell_cwd_path())
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// shell_cwd returns the working directory last published by the shell. An empty
|
||||||
|
// or relative path, or one that no longer exists, is treated as unknown rather
|
||||||
|
// than followed, as the shell may be between two writes.
|
||||||
|
func (s *shell_sync) shell_cwd() string {
|
||||||
|
b, err := os.ReadFile(s.shell_cwd_path())
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
p := strings.TrimSpace(string(b))
|
||||||
|
if !filepath.IsAbs(p) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if info, err := os.Stat(p); err != nil || !info.IsDir() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
// new_target returns the directory the panel should move to, or "" when the
|
||||||
|
// shell has not moved since the last call or already sits in current.
|
||||||
|
func (s *shell_sync) new_target(current string) string {
|
||||||
|
p := s.shell_cwd()
|
||||||
|
if p == "" || p == s.last {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
s.last = p
|
||||||
|
if p == current {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
// publish_request hands a directory to the shell. The write goes through a
|
||||||
|
// temporary file so that the shell never reads a half written path.
|
||||||
|
func (s *shell_sync) publish_request(dir string) error {
|
||||||
|
tmp := s.request_path() + ".tmp"
|
||||||
|
if err := os.WriteFile(tmp, []byte(dir), 0o600); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return os.Rename(tmp, s.request_path())
|
||||||
|
}
|
||||||
|
|
||||||
|
// withdraw_request cancels a request the shell has not read yet. Removing a
|
||||||
|
// request it already consumed is not an error, the shell removes it itself.
|
||||||
|
func (s *shell_sync) withdraw_request() {
|
||||||
|
_ = os.Remove(s.request_path())
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
// License: GPLv3 Copyright: 2026, FWS
|
||||||
|
|
||||||
|
package file_manager
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewShellSyncNeedsOptionDirectoryAndWindow(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
if s := new_shell_sync(dir, "7", false); s != nil {
|
||||||
|
t.Fatal("the sync must stay off until the option is enabled")
|
||||||
|
}
|
||||||
|
if s := new_shell_sync("", "7", true); s != nil {
|
||||||
|
t.Fatal("the sync must be off without a session directory")
|
||||||
|
}
|
||||||
|
if s := new_shell_sync(dir, "", true); s != nil {
|
||||||
|
t.Fatal("the sync must be off without a shell window id")
|
||||||
|
}
|
||||||
|
if s := new_shell_sync(filepath.Join(dir, "missing"), "7", true); s != nil {
|
||||||
|
t.Fatal("the sync must be off when the session directory is missing")
|
||||||
|
}
|
||||||
|
if s := new_shell_sync(dir, "7", true); s == nil {
|
||||||
|
t.Fatal("the sync must be on with an option, a directory and a window id")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPublishRequestIsReadableAndLeavesNoTemporaryFile(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
s := new_shell_sync(dir, "42", true)
|
||||||
|
if err := s.publish_request("/tmp/target dir"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, err := os.ReadFile(filepath.Join(dir, "42.set"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if string(got) != "/tmp/target dir" {
|
||||||
|
t.Fatalf("unexpected request payload %q", got)
|
||||||
|
}
|
||||||
|
if _, err = os.Stat(filepath.Join(dir, "42.set.tmp")); err == nil {
|
||||||
|
t.Fatal("the temporary file must be renamed, not left behind")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShellHasHookNeedsAPublishedDirectory(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
s := new_shell_sync(dir, "5", true)
|
||||||
|
if s.shell_has_hook() {
|
||||||
|
t.Fatal("the shell published nothing yet")
|
||||||
|
}
|
||||||
|
if err := s.publish_request(dir); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if s.shell_has_hook() {
|
||||||
|
t.Fatal("a request must not be mistaken for a published directory")
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, "5"), []byte(dir), 0o600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !s.shell_has_hook() {
|
||||||
|
t.Fatal("a published directory means the shell has the hook")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPublishBrowseNeedsTheShellHookAndCanBeWithdrawn(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
h := &Handler{sync: new_shell_sync(dir, "11", true), cwd: dir}
|
||||||
|
h.publish_browse()
|
||||||
|
if _, err := os.Stat(filepath.Join(dir, "11.set")); err == nil {
|
||||||
|
t.Fatal("the panel must not publish before the shell proved it has the hook")
|
||||||
|
}
|
||||||
|
if h.sync_published {
|
||||||
|
t.Fatal("nothing was published")
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, "11"), []byte(dir), 0o600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
h.publish_browse()
|
||||||
|
if got, err := os.ReadFile(filepath.Join(dir, "11.set")); err != nil || string(got) != dir {
|
||||||
|
t.Fatalf("unexpected request %q (%v)", got, err)
|
||||||
|
}
|
||||||
|
if !h.sync_published {
|
||||||
|
t.Fatal("the request must be remembered so that quitting can withdraw it")
|
||||||
|
}
|
||||||
|
h.withdraw_sync_request()
|
||||||
|
if _, err := os.Stat(filepath.Join(dir, "11.set")); err == nil {
|
||||||
|
t.Fatal("quitting must withdraw the pending request")
|
||||||
|
}
|
||||||
|
if h.sync_published {
|
||||||
|
t.Fatal("nothing is pending anymore")
|
||||||
|
}
|
||||||
|
h.withdraw_sync_request()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestShellCwdIgnoresUnusablePaths(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
s := new_shell_sync(dir, "9", true)
|
||||||
|
published := filepath.Join(dir, "9")
|
||||||
|
for _, content := range []string{"", " \n", "relative/path", filepath.Join(dir, "gone")} {
|
||||||
|
if err := os.WriteFile(published, []byte(content), 0o600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if got := s.shell_cwd(); got != "" {
|
||||||
|
t.Fatalf("%q must not be followed, got %q", content, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if got := s.shell_cwd(); got != "" {
|
||||||
|
t.Fatalf("a missing file must not be followed, got %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewTargetFollowsEachShellMoveOnce(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
s := new_shell_sync(dir, "3", true)
|
||||||
|
moved := t.TempDir()
|
||||||
|
s.last = dir
|
||||||
|
if got := s.new_target(dir); got != "" {
|
||||||
|
t.Fatalf("the shell has not moved yet, got %q", got)
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, "3"), []byte(moved), 0o600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if got := s.new_target(dir); got != moved {
|
||||||
|
t.Fatalf("wanted %q, got %q", moved, got)
|
||||||
|
}
|
||||||
|
if got := s.new_target(dir); got != "" {
|
||||||
|
t.Fatalf("a shell move must only be followed once, got %q", got)
|
||||||
|
}
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, "3"), []byte(dir), 0o600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if got := s.new_target(dir); got != "" {
|
||||||
|
t.Fatalf("moving to the directory already displayed must be a no-op, got %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestResultPayloadAdvertisesSyncOnlyWhenHandled(t *testing.T) {
|
||||||
|
h := &Handler{result_action: "cd", result_path: "/tmp"}
|
||||||
|
if payload := h.result_payload(); len(payload) != 2 {
|
||||||
|
t.Fatalf("the shell must be typed into when the sync did not handle the move: %#v", payload)
|
||||||
|
}
|
||||||
|
h.sync_handled = true
|
||||||
|
payload := h.result_payload()
|
||||||
|
if payload["sync"] != "1" || payload["path"] != "/tmp" {
|
||||||
|
t.Fatalf("unexpected payload: %#v", payload)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# License: GPLv3 Copyright: 2026, FWS
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# License: GPLv3 Copyright: 2026, FWS
|
||||||
|
|
||||||
|
# The keybindings live in the Python options object, while the searchable list
|
||||||
|
# UI lives in the Go command palette. Collect the data here, then replace this
|
||||||
|
# process with the palette reading the same terminal, so the panel can run in a
|
||||||
|
# dock without a second protocol between the two.
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
from contextlib import suppress
|
||||||
|
|
||||||
|
help_text = 'Browse all keyboard shortcuts in a searchable panel'
|
||||||
|
usage = ''
|
||||||
|
OPTIONS = r"""
|
||||||
|
""".format
|
||||||
|
|
||||||
|
|
||||||
|
def main(args: list[str]) -> None:
|
||||||
|
from kittens.command_palette.main import collect_keys_data
|
||||||
|
from kitty.config import load_config
|
||||||
|
from kitty.constants import config_dir, kitten_exe
|
||||||
|
|
||||||
|
conf = os.path.join(config_dir, 'kitty.conf')
|
||||||
|
opts = load_config(conf) if os.path.exists(conf) else load_config()
|
||||||
|
fd, path = tempfile.mkstemp(prefix='kitty-shortcuts-', suffix='.json')
|
||||||
|
try:
|
||||||
|
with os.fdopen(fd, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(collect_keys_data(opts), f)
|
||||||
|
exe = kitten_exe()
|
||||||
|
os.execv(exe, [exe, 'command-palette', '--data-file=' + path, '--read-only'])
|
||||||
|
finally:
|
||||||
|
# execv only returns on failure; on success the Go side removes the file.
|
||||||
|
with suppress(OSError):
|
||||||
|
os.unlink(path)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main(sys.argv)
|
||||||
|
elif __name__ == '__doc__':
|
||||||
|
cd = sys.cli_docs # type: ignore
|
||||||
|
cd['usage'] = usage
|
||||||
|
cd['options'] = OPTIONS
|
||||||
|
cd['help_text'] = help_text
|
||||||
|
cd['short_desc'] = 'Browse all keyboard shortcuts in a searchable panel'
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
import termios
|
import termios
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence
|
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence
|
||||||
@@ -21,6 +22,20 @@ if TYPE_CHECKING:
|
|||||||
from .window import CwdRequest
|
from .window import CwdRequest
|
||||||
|
|
||||||
|
|
||||||
|
@run_once
|
||||||
|
def cwd_sync_dir() -> str:
|
||||||
|
"""Directory shared by every window of this instance for the file manager's
|
||||||
|
working directory sync. It is created with private permissions so that only
|
||||||
|
this user can read the paths the shells publish, and lives in the runtime
|
||||||
|
directory, which the login session already clears. An empty string means the
|
||||||
|
sync is unavailable and the participating kittens keep their own behaviour."""
|
||||||
|
base = os.environ.get('XDG_RUNTIME_DIR')
|
||||||
|
try:
|
||||||
|
return tempfile.mkdtemp(prefix='kitty-cwd-sync-', dir=base if base and os.path.isdir(base) else None)
|
||||||
|
except OSError:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
from kitty.fast_data_types import abspath_of_process as _abspath_of_process
|
from kitty.fast_data_types import abspath_of_process as _abspath_of_process
|
||||||
from kitty.fast_data_types import cmdline_of_process as cmdline_
|
from kitty.fast_data_types import cmdline_of_process as cmdline_
|
||||||
@@ -464,6 +479,7 @@ class Child:
|
|||||||
elif opts.terminfo_type == 'direct':
|
elif opts.terminfo_type == 'direct':
|
||||||
env['TERMINFO'] = base64_terminfo_data()
|
env['TERMINFO'] = base64_terminfo_data()
|
||||||
env['KITTY_INSTALLATION_DIR'] = kitty_base_dir
|
env['KITTY_INSTALLATION_DIR'] = kitty_base_dir
|
||||||
|
env['KITTY_CWD_SYNC_DIR'] = cwd_sync_dir()
|
||||||
self.unmodified_argv = list(self.argv)
|
self.unmodified_argv = list(self.argv)
|
||||||
if not self.should_run_via_run_shell_kitten and 'disabled' not in opts.shell_integration:
|
if not self.should_run_via_run_shell_kitten and 'disabled' not in opts.shell_integration:
|
||||||
from .shell_integration import modify_shell_environ
|
from .shell_integration import modify_shell_environ
|
||||||
|
|||||||
@@ -424,8 +424,10 @@ handle_fast_commandline(CLISpec *cli_spec, const char *instance_group_prefix) {
|
|||||||
if (get_bool_cli_val(cli_spec, "version")) {
|
if (get_bool_cli_val(cli_spec, "version")) {
|
||||||
if (isatty(STDOUT_FILENO)) {
|
if (isatty(STDOUT_FILENO)) {
|
||||||
printf("\x1b[3mkitty\x1b[23m \x1b[32m%s\x1b[39m created by \x1b[1;34mKovid Goyal\x1b[22;39m\n", KITTY_VERSION);
|
printf("\x1b[3mkitty\x1b[23m \x1b[32m%s\x1b[39m created by \x1b[1;34mKovid Goyal\x1b[22;39m\n", KITTY_VERSION);
|
||||||
|
printf("\x1b[3mfws-kitty\x1b[23m \x1b[32m0.1.6\x1b[39m by \x1b[1;34mBlackAngelTV\x1b[22;39m\n");
|
||||||
} else {
|
} else {
|
||||||
printf("kitty %s created by Kovid Goyal\n", KITTY_VERSION);
|
printf("kitty %s created by Kovid Goyal\n", KITTY_VERSION);
|
||||||
|
printf("fws-kitty 0.1.6 by BlackAngelTV\n");
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2450,7 +2450,7 @@ lines is wrapped independently.
|
|||||||
|
|
||||||
opt(
|
opt(
|
||||||
'tab_title_template',
|
'tab_title_template',
|
||||||
'"{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}"',
|
'"{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{tab.active_wd_abbreviated} {title}"',
|
||||||
option_type='tab_title_template',
|
option_type='tab_title_template',
|
||||||
long_text="""
|
long_text="""
|
||||||
A template to render the tab title. The default just renders the title with
|
A template to render the tab title. The default just renders the title with
|
||||||
@@ -4685,6 +4685,16 @@ map('Show documentation', 'show_kitty_doc kitty_mod+f1 show_kitty_doc overview')
|
|||||||
|
|
||||||
map('Command palette', 'command_palette kitty_mod+f3 command_palette')
|
map('Command palette', 'command_palette kitty_mod+f3 command_palette')
|
||||||
|
|
||||||
|
map(
|
||||||
|
'Keyboard shortcuts',
|
||||||
|
'keyboard_shortcuts kitty_mod+h launch --type=window-dock --dock-edge=left --dock-size=60 kitty +kitten help',
|
||||||
|
long_text="""
|
||||||
|
Open the searchable keyboard shortcuts panel in a dock at the left edge of the
|
||||||
|
current window. It can also be launched manually with :code:`kitty +kitten help`.
|
||||||
|
The default binding is :kbd:`kitty_mod+h` (:kbd:`Ctrl+Shift+H` by default).
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
map(
|
map(
|
||||||
'File manager',
|
'File manager',
|
||||||
'file_manager ctrl+shift+e launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager',
|
'file_manager ctrl+shift+e launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager',
|
||||||
|
|||||||
Generated
+3
-1
@@ -704,7 +704,7 @@ class Options:
|
|||||||
tab_switch_strategy: choices_for_tab_switch_strategy = 'previous'
|
tab_switch_strategy: choices_for_tab_switch_strategy = 'previous'
|
||||||
tab_title_max_length: int = 0
|
tab_title_max_length: int = 0
|
||||||
tab_title_max_lines: int = 1
|
tab_title_max_lines: int = 1
|
||||||
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}'
|
tab_title_template: str = '{fmt.fg.red}{bell_symbol}{activity_symbol}{exit_status_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{tab.active_wd_abbreviated} {title}'
|
||||||
tab_title_wrap: int = 0
|
tab_title_wrap: int = 0
|
||||||
term: str = 'xterm-kitty'
|
term: str = 'xterm-kitty'
|
||||||
terminfo_type: choices_for_terminfo_type = 'path'
|
terminfo_type: choices_for_terminfo_type = 'path'
|
||||||
@@ -1036,6 +1036,8 @@ defaults.map = [
|
|||||||
KeyDefinition(trigger=SingleKey(mods=256, key=57366), definition='command_palette'),
|
KeyDefinition(trigger=SingleKey(mods=256, key=57366), definition='command_palette'),
|
||||||
# file_manager
|
# file_manager
|
||||||
KeyDefinition(trigger=SingleKey(mods=5, key=101), definition='launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager'),
|
KeyDefinition(trigger=SingleKey(mods=5, key=101), definition='launch --type=window-dock --dock-edge=left --dock-size=60 kitten file-manager'),
|
||||||
|
# keyboard_shortcuts
|
||||||
|
KeyDefinition(trigger=SingleKey(mods=5, key=104), definition='launch --type=window-dock --dock-edge=left --dock-size=60 kitty +kitten help'),
|
||||||
# toggle_fullscreen
|
# toggle_fullscreen
|
||||||
KeyDefinition(trigger=SingleKey(mods=256, key=57374), definition='toggle_fullscreen'),
|
KeyDefinition(trigger=SingleKey(mods=256, key=57374), definition='toggle_fullscreen'),
|
||||||
# toggle_maximized
|
# toggle_maximized
|
||||||
|
|||||||
@@ -927,6 +927,17 @@ class Tab: # {{{
|
|||||||
restored_scrollback: bytes = b'',
|
restored_scrollback: bytes = b'',
|
||||||
) -> Window:
|
) -> Window:
|
||||||
"Create a new window. When dock is specified, the window is docked to dock_owner or to the tab if dock_owner is None."
|
"Create a new window. When dock is specified, the window is docked to dock_owner or to the tab if dock_owner is None."
|
||||||
|
# A special window opened over another one, or docked next to it, needs
|
||||||
|
# to know which shell it belongs to: the file manager uses it to find
|
||||||
|
# the session file where that shell publishes its working directory. A
|
||||||
|
# dock follows a window group, so its initial parent is the active
|
||||||
|
# window of the tab it is created in.
|
||||||
|
parent_window_id = overlay_for
|
||||||
|
if parent_window_id is None and dock is not None and (aw := self.active_window) is not None:
|
||||||
|
parent_window_id = aw.id
|
||||||
|
if parent_window_id is not None:
|
||||||
|
env = dict(env or {})
|
||||||
|
env['KITTY_SPECIAL_WINDOW_PARENT'] = str(parent_window_id)
|
||||||
cs = WindowCreationSpec(
|
cs = WindowCreationSpec(
|
||||||
use_shell=use_shell,
|
use_shell=use_shell,
|
||||||
cmd=cmd,
|
cmd=cmd,
|
||||||
|
|||||||
@@ -213,6 +213,10 @@ _ksi_main() {
|
|||||||
builtin printf "\e]7;kitty-shell-cwd://%s%s\a" "$HOSTNAME" "$PWD"
|
builtin printf "\e]7;kitty-shell-cwd://%s%s\a" "$HOSTNAME" "$PWD"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${_ksi_cwd_sync_file:-}" ]]; then
|
||||||
|
_ksi_cwd_sync_apply
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "${_ksi_prompt[cursor]}" == "y" ]]; then
|
if [[ "${_ksi_prompt[cursor]}" == "y" ]]; then
|
||||||
@@ -265,8 +269,34 @@ _ksi_main() {
|
|||||||
_ksi_prompt[ps2]+="\[\e]133;A;k=s\a\]"
|
_ksi_prompt[ps2]+="\[\e]133;A;k=s\a\]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
builtin alias edit-in-kitty="kitten edit-in-kitty"
|
# Optional working directory sync with the file manager panel (sync_cwd).
|
||||||
|
# The panel publishes the directory it wants in <dir>/<window id>.set and we
|
||||||
|
# apply it at prompt time instead of typing a cd into the terminal: the
|
||||||
|
# command stays out of the history and a half typed multi-line command is
|
||||||
|
# not submitted. We publish our own directory the same way so that the panel
|
||||||
|
# can follow a cd made here.
|
||||||
|
if [[ -n "$KITTY_CWD_SYNC_DIR" && -n "$KITTY_WINDOW_ID" && -d "$KITTY_CWD_SYNC_DIR" ]]; then
|
||||||
|
_ksi_cwd_sync_file="$KITTY_CWD_SYNC_DIR/$KITTY_WINDOW_ID"
|
||||||
|
_ksi_cwd_sync_publish() {
|
||||||
|
builtin printf '%s' "$PWD" > "$_ksi_cwd_sync_file" 2> /dev/null
|
||||||
|
builtin return 0
|
||||||
|
}
|
||||||
|
_ksi_cwd_sync_apply() {
|
||||||
|
builtin local ret=$? target
|
||||||
|
if [[ -f "$_ksi_cwd_sync_file.set" ]]; then
|
||||||
|
IFS= builtin read -r target < "$_ksi_cwd_sync_file.set"
|
||||||
|
builtin command rm -f -- "$_ksi_cwd_sync_file.set"
|
||||||
|
if [[ -n "$target" && -d "$target" ]]; then
|
||||||
|
builtin cd -- "$target"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_ksi_cwd_sync_publish
|
||||||
|
builtin return $ret
|
||||||
|
}
|
||||||
|
_ksi_cwd_sync_publish
|
||||||
|
fi
|
||||||
|
|
||||||
|
builtin alias edit-in-kitty="kitten edit-in-kitty"
|
||||||
|
|
||||||
if [[ "${_ksi_prompt[complete]}" == "y" ]]; then
|
if [[ "${_ksi_prompt[complete]}" == "y" ]]; then
|
||||||
_ksi_completions() {
|
_ksi_completions() {
|
||||||
@@ -315,6 +345,7 @@ _ksi_main() {
|
|||||||
# from the shell
|
# from the shell
|
||||||
builtin local pc
|
builtin local pc
|
||||||
pc='builtin declare -F _ksi_prompt_command > /dev/null 2> /dev/null && _ksi_prompt_command'
|
pc='builtin declare -F _ksi_prompt_command > /dev/null 2> /dev/null && _ksi_prompt_command'
|
||||||
|
if [[ -n "${_ksi_cwd_sync_file:-}" ]]; then pc="$pc; _ksi_cwd_sync_apply"; fi
|
||||||
if [[ -z "${PROMPT_COMMAND[*]}" ]]; then
|
if [[ -z "${PROMPT_COMMAND[*]}" ]]; then
|
||||||
PROMPT_COMMAND=([0]="$pc")
|
PROMPT_COMMAND=([0]="$pc")
|
||||||
elif [[ $(builtin declare -p PROMPT_COMMAND 2> /dev/null) =~ 'declare -a PROMPT_COMMAND' ]]; then
|
elif [[ $(builtin declare -p PROMPT_COMMAND 2> /dev/null) =~ 'declare -a PROMPT_COMMAND' ]]; then
|
||||||
|
|||||||
@@ -137,6 +137,28 @@ function __ksi_schedule --on-event fish_prompt -d "Setup kitty integration after
|
|||||||
__update_cwd_osc
|
__update_cwd_osc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Optional working directory sync with the file manager panel (sync_cwd).
|
||||||
|
# The panel publishes the directory it wants in <dir>/<window id>.set and we
|
||||||
|
# apply it at prompt time instead of typing a cd into the terminal, see the
|
||||||
|
# bash integration for the rationale.
|
||||||
|
if set -q KITTY_CWD_SYNC_DIR; and set -q KITTY_WINDOW_ID; and test -d "$KITTY_CWD_SYNC_DIR"
|
||||||
|
function __ksi_cwd_sync_publish --on-event fish_prompt -d "Publish the working directory for the file manager panel"
|
||||||
|
printf '%s' "$PWD" > "$KITTY_CWD_SYNC_DIR/$KITTY_WINDOW_ID" 2> /dev/null
|
||||||
|
end
|
||||||
|
function __ksi_cwd_sync_apply --on-event fish_prompt -d "Apply a directory chosen in the file manager panel"
|
||||||
|
set --local file "$KITTY_CWD_SYNC_DIR/$KITTY_WINDOW_ID.set"
|
||||||
|
if test -f "$file"
|
||||||
|
set --local target (cat "$file")
|
||||||
|
rm -f -- "$file"
|
||||||
|
if test -n "$target" -a -d "$target"
|
||||||
|
builtin cd -- "$target"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
__ksi_cwd_sync_publish
|
||||||
|
end
|
||||||
|
__ksi_cwd_sync_publish
|
||||||
|
end
|
||||||
|
|
||||||
# Note that neither alias nor function is recursive in fish so if the user defines an alias/function
|
# Note that neither alias nor function is recursive in fish so if the user defines an alias/function
|
||||||
# for sudo/run0 it will be clobbered by us, so only install these if they are not already functions
|
# for sudo/run0 it will be clobbered by us, so only install these if they are not already functions
|
||||||
if not contains "no-sudo" $_ksi
|
if not contains "no-sudo" $_ksi
|
||||||
|
|||||||
@@ -246,6 +246,31 @@ _ksi_deferred_init() {
|
|||||||
_ksi_report_pwd
|
_ksi_report_pwd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Optional working directory sync with the file manager panel (sync_cwd).
|
||||||
|
# The panel publishes the directory it wants in <dir>/<window id>.set and we
|
||||||
|
# apply it at prompt time instead of typing a cd into the terminal, see the
|
||||||
|
# bash integration for the rationale.
|
||||||
|
if [[ -n $KITTY_CWD_SYNC_DIR && -n $KITTY_WINDOW_ID && -d $KITTY_CWD_SYNC_DIR ]]; then
|
||||||
|
builtin typeset -g _ksi_cwd_sync_file="$KITTY_CWD_SYNC_DIR/$KITTY_WINDOW_ID"
|
||||||
|
_ksi_cwd_sync_publish() { builtin print -rn -- "$PWD" >| "$_ksi_cwd_sync_file" 2> /dev/null; }
|
||||||
|
_ksi_cwd_sync_apply() {
|
||||||
|
builtin local -i ret=$?
|
||||||
|
builtin local target
|
||||||
|
if [[ -f "$_ksi_cwd_sync_file.set" ]]; then
|
||||||
|
IFS= builtin read -r target < "$_ksi_cwd_sync_file.set"
|
||||||
|
builtin command rm -f -- "$_ksi_cwd_sync_file.set"
|
||||||
|
if [[ -n $target && -d $target ]]; then
|
||||||
|
builtin cd -- "$target"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_ksi_cwd_sync_publish
|
||||||
|
builtin return ret
|
||||||
|
}
|
||||||
|
_ksi_cwd_sync_publish
|
||||||
|
precmd_functions+=(_ksi_cwd_sync_apply)
|
||||||
|
chpwd_functions+=(_ksi_cwd_sync_publish)
|
||||||
|
fi
|
||||||
|
|
||||||
# Enable terminal title changes.
|
# Enable terminal title changes.
|
||||||
if (( ! opt[(Ie)no-title] )); then
|
if (( ! opt[(Ie)no-title] )); then
|
||||||
# We don't use `print -P` because it depends on prompt options, which
|
# We don't use `print -P` because it depends on prompt options, which
|
||||||
|
|||||||
+2
-1
@@ -30,7 +30,8 @@ func ShowError(err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Command) version_string(formatter *markup.Context) string {
|
func (self *Command) version_string(formatter *markup.Context) string {
|
||||||
return fmt.Sprintln(formatter.Italic(self.CommandStringForUsage()), formatter.Opt(kitty.VersionString+kitty.VersionSuffix), "created by", formatter.Title("Kovid Goyal"))
|
return fmt.Sprintln(formatter.Italic(self.CommandStringForUsage()), formatter.Opt(kitty.VersionString+kitty.VersionSuffix), "created by", formatter.Title("Kovid Goyal")) +
|
||||||
|
fmt.Sprintln(formatter.Italic("fws-kitty"), formatter.Opt("0.1.6"), "by", formatter.Title("BlackAngelTV"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Command) ShowVersion() {
|
func (self *Command) ShowVersion() {
|
||||||
|
|||||||
+21
-5
@@ -97,6 +97,21 @@ func shell_loop(rl *readline.Readline, kill_if_signaled bool) (int, error) {
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// launch_shortcuts_panel opens the searchable keybinding reference in a dock,
|
||||||
|
// next to the terminal, instead of taking over the shell window.
|
||||||
|
func launch_shortcuts_panel() int {
|
||||||
|
kitty := utils.KittyExe()
|
||||||
|
if kitty == "" {
|
||||||
|
kitty = "kitty"
|
||||||
|
}
|
||||||
|
root := cli.NewRootCommand()
|
||||||
|
EntryPoint(root)
|
||||||
|
return root.ExecArgs([]string{
|
||||||
|
"kitten", "@", "launch", "--type=window-dock", "--dock-edge=left", "--dock-size=60",
|
||||||
|
kitty, "+kitten", "help",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func show_basic_help() {
|
func show_basic_help() {
|
||||||
output := strings.Builder{}
|
output := strings.Builder{}
|
||||||
fmt.Fprintln(&output, "Control kitty by sending it commands.")
|
fmt.Fprintln(&output, "Control kitty by sending it commands.")
|
||||||
@@ -110,7 +125,7 @@ func show_basic_help() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Fprintln(&output, " ", formatter.Green("help"))
|
fmt.Fprintln(&output, " ", formatter.Green("help"))
|
||||||
fmt.Fprintln(&output, " ", "Show this help")
|
fmt.Fprintln(&output, " ", "Show keyboard shortcuts")
|
||||||
fmt.Fprintln(&output, " ", formatter.Green("exit"))
|
fmt.Fprintln(&output, " ", formatter.Green("exit"))
|
||||||
fmt.Fprintln(&output, " ", "Exit this shell")
|
fmt.Fprintln(&output, " ", "Exit this shell")
|
||||||
cli.ShowHelpInPager(output.String())
|
cli.ShowHelpInPager(output.String())
|
||||||
@@ -136,14 +151,14 @@ func exec_command(at_root_command *cli.Command, rl *readline.Readline, cmdline s
|
|||||||
hi.ExitCode = 0
|
hi.ExitCode = 0
|
||||||
defer rl.AddHistoryItem(hi)
|
defer rl.AddHistoryItem(hi)
|
||||||
if len(parsed_cmdline) == 1 {
|
if len(parsed_cmdline) == 1 {
|
||||||
show_basic_help()
|
hi.ExitCode = launch_shortcuts_panel()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
switch parsed_cmdline[1] {
|
switch parsed_cmdline[1] {
|
||||||
case "exit":
|
case "exit":
|
||||||
fmt.Println("Exit this shell")
|
fmt.Println("Exit this shell")
|
||||||
case "help":
|
case "help":
|
||||||
fmt.Println("Show help")
|
fmt.Println("Show keyboard shortcuts")
|
||||||
default:
|
default:
|
||||||
sc := at_root_command.FindSubCommand(parsed_cmdline[1])
|
sc := at_root_command.FindSubCommand(parsed_cmdline[1])
|
||||||
if sc == nil {
|
if sc == nil {
|
||||||
@@ -190,7 +205,7 @@ func completions(before_cursor, after_cursor string) (ans *cli.Completions) {
|
|||||||
}
|
}
|
||||||
x.ShortDescription = desc
|
x.ShortDescription = desc
|
||||||
}
|
}
|
||||||
add_sc("help", "Show help")
|
add_sc("help", "Show keyboard shortcuts")
|
||||||
add_sc("exit", "Exit the kitty shell")
|
add_sc("exit", "Exit the kitty shell")
|
||||||
root.Validate()
|
root.Validate()
|
||||||
ans = root.GetCompletions(argv, nil)
|
ans = root.GetCompletions(argv, nil)
|
||||||
@@ -206,7 +221,8 @@ func shell_main(cmd *cli.Command, args []string) (int, error) {
|
|||||||
running_shell = true
|
running_shell = true
|
||||||
formatter = markup.New(true)
|
formatter = markup.New(true)
|
||||||
fmt.Println("Welcome to the kitty shell!")
|
fmt.Println("Welcome to the kitty shell!")
|
||||||
fmt.Println("Use", formatter.Green("help"), "for assistance or", formatter.Green("exit"), "to quit.")
|
fmt.Println("Use", formatter.Green("Ctrl+Shift+H"), "or", formatter.Green("help"), "for the keyboard shortcuts panel.")
|
||||||
|
fmt.Println("Use", formatter.Green("help <command>"), "for a command's help, or", formatter.Green("exit"), "to quit.")
|
||||||
if atwid := os.Getenv("KITTY_SHELL_ACTIVE_WINDOW_ID"); atwid != "" {
|
if atwid := os.Getenv("KITTY_SHELL_ACTIVE_WINDOW_ID"); atwid != "" {
|
||||||
amsg := "Previously active window id: " + atwid
|
amsg := "Previously active window id: " + atwid
|
||||||
os.Unsetenv("KITTY_SHELL_ACTIVE_WINDOW_ID")
|
os.Unsetenv("KITTY_SHELL_ACTIVE_WINDOW_ID")
|
||||||
|
|||||||
Reference in new issue
Block a user