An open API service indexing awesome lists of open source software.

https://github.com/knu/zsh-shell-word-at-point

zle function to get a shell word at point
https://github.com/knu/zsh-shell-word-at-point

Last synced: about 1 year ago
JSON representation

zle function to get a shell word at point

Awesome Lists containing this project

README

          

shell-word-at-point for zsh
===========================

Synopsis
--------

* shell-word-at-point - zle function to get a shell word at point

Description
-----------

Unless I am missing something, zsh does not provide the "ffap"
(find-file-at-point) functionality out of the box. This library
provides the following functions to fill the needs.

- `shell-word-at-point` sets the global variable `shell_word` to the
raw shell word at point and `shell_word_position` to the zero-based
index of where it starts.

- `copy-whole-shell-word` copies the shell word at point as kill.

- `kill-whole-shell-word` kills the shell word at point.

- `edit-file-at-point` invokes `EDITOR` (default: `vi`) passing a file
name at point.

- `view-file-at-point` invokes `PAGER` (default: `more`) passing a
file name at point.

- `run-shell-word-at-point` opens a new command line with only the
current shell word set, pushing the whole command line with
`push-line`.

After closing `EDITOR` or `PAGER`, you will be back on the command
line exactly with the previous status.

How to set up
-------------

Put the file `shell-word-at-point` somewhere in your `$fpath` and add
these lines to your `.zshrc`:

autoload -Uz shell-word-at-point
shell-word-at-point

Here's example bindings for Emacs users:

bindkey '^[^W' copy-whole-shell-word
bindkey '^[^K' kill-whole-shell-word
bindkey '^X^F' edit-file-at-point
bindkey '^X^R' view-file-at-point
bindkey '^[!' run-shell-word-at-point

License
-------

Copyright (c) 2015-2024 Akinori MUSHA

Licensed under the 2-clause BSD license.
See `LICENSE` for details.