Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/helicPublic

Clipboard synchronization tool

License

NotificationsYou must be signed in to change notification settings

tek/helic

Repository files navigation

Helic is a tool for synchronizing clipboard contents acrossX11,tmux and network, consisting of a daemonlistening for changes and a CLI client for use in programs likeNeovim.

X11 has three separate copy buffers, called theclipboard, theprimary selection and thesecondary selection.Selections are used when text is selected with the mouse, while the clipboard is updated byCtrl-C.

When some text is copied or selected inX11, the daemon receives an event that it proceeds to broadcast to theconfigured targets.If the source was a selection, theX11 clipboard is updated as well.

The CLI programhel can be used to manually send text to the daemon, for example fromtmux orNeovim.If remote hosts are configured, each yank event is sent over the network to update their clipboards.

Several yank events are stored in memory in order to detect duplicates and cycles.

The CLI understands four different commands:

CommandMeaning
hel listenStart the daemon. This is best done from asystemd user service.
hel yankSend standard input or argument to the daemon as a manual yank event.
hel listPrint the event history.
hel loadLoad an older event to the clipboard, given its index into the history.

Thelist command will print a table like this:

╭───┬──────────┬───────┬──────────┬──────────────────────────╮│ # │ Instance │ Agent │   Time   │         Content          │╞═══╪══════════╪═══════╪══════════╪══════════════════════════╡│ 2 │   test   │ nvim  │ 12:00:00 │ single line              │├───┼──────────┼───────┼──────────┼──────────────────────────┤│ 1 │   test   │ nvim  │ 12:00:00 │ single line with newline │├───┼──────────┼───────┼──────────┼──────────────────────────┤│ 0 │   test   │ nvim  │ 12:00:00 │ three lines 1 [3 lines]  │╰───┴──────────┴───────┴──────────┴──────────────────────────╯

The index in the first column, with 0 being the latest event, can be used withhel load.

Installing and Running Helic

Nix

The project uses aNixflake to configure its build, and it is recommended to install or run it usingNix as well.IfNix is installed and configured for use withflakes, the app can be run without installation like this:

$ nix run github:tek/helic -- listen$echo'yank me'| nix run github:tek/helic -- yank --agent cli$ nix run github:tek/helic -- list 100$ nix run github:tek/helic -- load 5

NixOS

The flake provides aNixOS module that can be used by adding it to/etc/nixos/flake.nix:

{inputs.helic.url="github:tek/helic";outputs={nixpkgs,helic, ...}:{nixosConfigurations.myhost=nixpkgs.lib.nixosSystem{modules=[helic.nixosModules.default];services.helic.enable=true;};};}

With this, asystemd user service will be started on login and the client will be in$PATH:

$echo'yank me'| hel yank$ hel yank --agent custom-name --text'yank me'

After a rebuild, the service may not be started right away, so this command must be executed:

$ systemctl --user start helic

Globally enabledsystemd user services are started for all users on login.To prevent that, you can set the module optionservices.helic.user = "myuser".

Without Nix

Alternatively, the app can be installed using aHaskell package manager, likeCabal:

$ cabal install helic$ hel listen

CLI

If no command has been specified explicitly,Helic decides which one to start by the presence of stdin data:

$ hel# start daemon$echo'yank me'| hel# yank

Global CLI options are specifiedbefore the command name, command-specific ones after it.

CommandNameDescription
Global--verboseIncrease the log level.
Global--config-file FILEUse the specified file path instead of the default locations.
listen--agent NAMEUsed to avoid sending yanks back to the application that sent them.
listpositional (hel list 5)Limit the number of printed events.
loadpositional (hel load 5)Choose the index of the event to be loaded.
yank--agent NAMECustom name used in thelist output and to avoid cycles.
yank--text TEXTYank text, uses stdin if not specified.

Configuring Helic

The app reads the first existing one of these three configuration files:

  • The file specified with--config-file
  • $XDG_CONFIG_DIR/helic.yaml (most likely~/.config/helic.yaml)
  • /etc/helic.yaml

An example config file looks like this:

name:myhostmaxHistory:1000debounceMillis:3000verbose:truenet:enable:trueport:10001hosts:    -"remote1:1000"    -"remote2:2000"timeout:5tmux:enable:trueexe:/bin/tmuxx11:enable:truedisplay:":0"

ForNixOS, the file/etc/helic.yaml is generated from module options:

{services.helic={enable=true;name="myhost";maxHistory=1000;debounceMillis=3000;verbose=true;user="myuser";net={enable=true;port=10001;hosts=["remote1:1000""remote2:2000"];timeout=5;};tmux={enable=true;package=pkgs.tmux;};x11={enable=true;display=":0";};};}

The meaning of these options is:

KeyDefaultDescription
nameHost nameAn identifier for the host, used for filtering duplicates.
usernullOnly forNixOS: If set, only start the service for that user.
maxHistory100The number of yanks that should be kept.
debounceMillis3000The interval in milliseconds during which the same text is ignored.
verboseIncrease the log level.
net.enabletrueWhether to send events over the network.
net.port9500The HTTP port the daemon listens to for both remote sync andhel yank.
net.hosts[]The addresses (with port) of the hosts to which this instance should broadcast yank events.
net.timeout300The timeout in milliseconds for requests to remote hosts.
tmux.enabletrueWhether to send events totmux.
tmux.packagepkgs.tmuxOnly forNixOS: Thenixpkgs package used for thetmux executable.
tmux.exetmuxOnly for YAML file: The path to thetmux executable
x11.enabletrueWhether to synchronize the X11 clipboard.
x11.display:0The display identifier used when connecting to the default display via GTK fails.

Neovim

Neovim's clipboard requires configuration with a tool in any case, so changing it to usehel is simple:

letg:clipboard= {\'name':'helic',\'copy': {\'+':'hel yank --agent nvim',\'*':'hel yank --agent nvim',\   },\'paste': {\'+':'xsel -bo',\'*':'xsel -bo',\  },\}

SinceHelic updates theX11 clipboard, a custompaste command is not necessary.

About

Clipboard synchronization tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp