Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
/ kitty_keys Public archive

A POSIX shell function to output keybindings for the kitty terminal emulator.

License

Notifications You must be signed in to change notification settings

flexibeast/kitty_keys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

kitty_keys.sh

NOTE: This repository is now read-only - official repository now at https://git.sr.ht/~flexibeast/kitty_keys

A POSIX function to print the current keybindings for the kitty terminal emulator.

To use it, source this repository's kitty_keys.sh file, e.g. as part of your shell's startup procedure. This will make the kitty_keys function available.

When called without arguments, or with any unknown arguments, kitty_keys will print the default keybindings, followed by any custom keybindings specified in the user's kitty configuration file.

With a single argument of one of copypaste, debugging, layouts, miscellaneous, scrolling, tabs, windows, print the default keybindings for that category. With a single argument of custom, print only the user's custom keybindings.

Completion can be added in zsh via:

function _kitty_keys {
    compadd 'copypaste' 'debugging' 'layouts' 'miscellaneous' 'scrolling' 'tabs' 'windows' 'custom'
}
compdef _kitty_keys kitty_keys

Limited configuration over the output format is available via the KITTY_KEYS_LEADING, KITTY_KEYS_TRAILING, KITTY_KEYS_MAX_WIDTH and KITTY_KEYS_CONF environment variables. Details in comments in the source.

This function has been lightly tested in the zsh, bash and dash shells. Any non-POSIX shell behaviour is a bug.

Design notes

  • POSIX shell doesn't provide associative arrays ('dictionaries', 'hashes', etc.), which would allow for a more concise script via the use of keybinding categories as keys in a loop.

  • echo is notoriously inconsistent across platforms and shells, so printf(1) is used instead in an attempt to reduce issues. Calling it via env ensures we get the command/utility, rather than the builtin. The print1 function provides a convenience wrapper.

  • Setting IFS to '' is used to try to make field splitting behaviour more uniform across shells.

About

A POSIX shell function to output keybindings for the kitty terminal emulator.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages