Skip to content

nagygr/keybindings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keybindings

This application parses application configs for keyboard shortcuts and echos them.

It uses information given in its config file for each application:

  • the application name: it is used in the command line arguments to tell Shortcuts which application's config to look for
  • the config's path: the path to the config file (either absolute path or relative to the user's home directory
  • the syntax: the regex that matches the lines that define shortcuts
    • the regex must contain two unnamed capturing groups: the first is the keyboard shortcut, the second is the command that's executed
    • the regex can contain any number of additional non-capturing groups
      • Form: (?:regex)

The config file is searched in: $HOME/.config/shortcuts/config.yml. If it is not found there then the directory is created and a default config file is placed there.

The default configuration:

applications:
    - name: i3
      path: .config/i3/config
      keybindingpattern: bindsym ([a-zA-Z0-9$+]+) (.*)
    - name: vim
      path: .vimrc
      keybindingpattern: (?:map|nmap|nnoremap|tnoremap) ((?:[a-zA-Z0-9<>-]|\\p{Punct})+) (.*)
    - name: vifm
      path: .config/vifm/vifmrc
      keybindingpattern: nnoremap ([a-zA-Z0-9<>,-]+) (.*)

There are two operating modes:

  1. Interactive:
    • when no command-line arguments are supplied to the application, it starts in interactive mode
    • it lists the application that have been configured and the user gets to choose one
    • it then lists the keybindings of the chosen application
  2. Autonomous:
    • the application can take exactly one command argument which can either be "-h" or "--help" or the name of an application
    • it prints a help message or the keybindings of the application

Compilation

The application needs to be compiled. In order to do that, a working Go build environment is needed. Please refer to your distribution's package manager or visit this page for information on how to install Go.

Note

Go can typically be installed using package managers, although it might not be the latest version that's available (especially if the package manager serves a point release distribution). Some install commands for popular package managers are:

Arch/Manjaro: pacman -S go Fedora: dnf install golang Ubuntu: apt-get install golang

Once Go is available on the system, the compilation can be performed by issuing:

go build -mod=mod -o build/keybindings ./cmd/keybindings

or by using the attached Makefile:

make all

The binary will be available in the build folder of the repositry root.

Installation

The application can also be installed from github using the following command:

go install github.com/nagygr/keybindings/cmd/keybindings@latest

Note

Please note, that the command above also requires Go to be installed on the system. Please see details about Go installation above.

About

Lists the keybindings of your favorite applications from local config files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published