Run commands on selected text quickly
Project description
Xtip
A semi-clone of tanin47's tip but for X11 (i.e. Linux).
Alpha stage, anything may change at any time.
Customised in python (but it's very easy to run shell commands from python if you prefer another language).
Installation and setup
- Install the core dependencies:
zenity,dmenu,xclip- e.g. on Debian-based OS:
sudo apt install zenity xclip suckless-tools
- e.g. on Debian-based OS:
- Install xtip from pypi, e.g.
pip3 install xtip - Bind a hotkey to run the
xtipcommand using your preferred method.- I use sxhkd, but I think most desktop environments have a hotkey binding system.
- Optionally install dependencies for any individual commands that you want to use:
- GoogleTranslate requires the python googtrans library
- Emacsclient requires emacs (obviously)
Writing your own commands
For most customisation of commands you should probably just write your own
(because it only takes a few lines of python). You can write new commands in
~/.config/xtip/custom_commands.py.
To do so: write a new class derived from Command and decorate it with
@command, for example:
from typing import Optional
from subprocess import run
from xtip.commands import Command, command
@command
class Emacsclient(Command):
unique_name = "Open in emacsclient"
def run(self, text: str) -> Optional[str]:
# TODO(david): Figure out a way to get the absolute path... maybe by
# guessing from a few possible prefixes?
run(["emacsclient", "-c", "-n", text])
# Return text from here to output it to the screen and clipboard
return None
def accepts(self, text: str) -> bool:
# TODO: only accept things that look like valid paths?
Return True
TODO: Do we need both inheritence and a decorator? Probably not!
TODO
- Write some tests
- CI builds
- Try to display useful outputs in dmenu completion (e.g. converted datetimes)
- Something better than dmenu? Better mouse support, popup at cursor.
- Figure out how to construct an absolute path from a relative one
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xtip-0.2.0.tar.gz.
File metadata
- Download URL: xtip-0.2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.6.9 Linux/5.3.0-51-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b45eebacd5dab69be3c5fcfac009ccff8125fddd21db749cdc19d91fbdcb153
|
|
| MD5 |
43fc512857d5b6755efd0a413103f6ad
|
|
| BLAKE2b-256 |
e51be39efb5988466a89d2f37ad30fc367d68595d269259d530a39cca130d406
|
File details
Details for the file xtip-0.2.0-py3-none-any.whl.
File metadata
- Download URL: xtip-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.6.9 Linux/5.3.0-51-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73e7b98d9666c7eed18b47fde5b9e71308a3cc454dacaf583ca0d50f426b3497
|
|
| MD5 |
04cae99ee7677f4c42685a175a41cddb
|
|
| BLAKE2b-256 |
50e62a9c4b4efb3c9f757003efcb6a85bf2cd5a3fa945e9fc61b232f4eeae82a
|