Giter Club home page Giter Club logo

uclip's Introduction

μclip: The Tiny CLI Clipboard

μclip is a simple, cli-based clipboard that operates on stdin and stdout. Its primary purpose is to provide a simple clipboard that can interface between tmux, vim, and system clipboards.

Install

Compile the uclip source file into a binary using your chosen C compiler. A few examples:

$ gcc -Wall -Wextra uclip.c -o uclip && \
  ln -s uclip /path/to/local/bin

# or:
$ clang -Wall -Wextra uclip.c -o uclip && \
  ln -s uclip /path/to/local/bin

Usage

# Write content to clipboard:
$ echo "Hello World" | uclip -i

# Print contents to stdout:
$ uclip -o

# Read file contents, but do not print any errors if they occur:
$ uclip -q -i < README.md

Integrations

Vim

For vim, you can yank and paste to uclip using ex commands:

# Copy entire register
:%w !uclip -i

# Or visual selection:
:'<,'>w !uclip -i

# To paste contents at line N:
:Nr !uclip -o

# To overwrite selection with clipboard contents:
:'<,'>!uclip -o

(Note: for nvim only) Alternatively, you can replace the system registers by adding the following to your vimrc:

let g:clipboard = {
    'name': 'uclip',
    'copy': {
        '+': ['uclip', '-i'],
        '*': ['uclip', '-i'],
    },
    'paste': {
        '+': ['uclip', '-o'],
        '*': ['uclip', '-o'],
    },
    'cache_enabled': 1,
}

Tmux

Yank

For vi keybinds, add the following to your tmux.conf:

bind -Tcopy-mode-vi y               send -X copy-pipe-and-cancel 'uclip -i'
bind -Tcopy-mode-vi C-j               send -X copy-pipe-and-cancel 'uclip -i'
bind -Tcopy-mode-vi Enter             send -X copy-pipe-and-cancel 'uclip -i'
bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel 'uclip -i'
set-option -s set-clipboard off

or for emacs keybinds, add the following:

bind -Tcopy-mode C-w               send -X copy-pipe-and-cancel 'uclip -i'
bind -Tcopy-mode M-w               send -X copy-pipe-and-cancel 'uclip -i'
bind -Tcopy-mode MouseDragEnd1Pane send -X copy-pipe-and-cancel 'uclip -i'

Note: this only works for tmux 2.4+. For earlier versions, see the official documentation

Paste

Coming soon

OS

Linux, macOS, and *BSD coming soon!

uclip's People

Contributors

ellislm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.