sjuxax / pisces

♓️ Fish shell plugin that helps you to work with paired symbols in the command line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pisces ☯ 双鱼

pisces ['paɪsiz] is a plugin for fish that helps you to work with paired symbols like () and '' in the command line. Just as in your favorite text editor!

Features

Here | denotes the current cursor position. No manual cursor motion involved ✨

  • autocloses pair symbol:
    ... | + (
    ... (|)
  • skips the closing symbol:
    ...|) + )
    ... )|
  • removes empty pairs:
    ...([|]) + backspace
    ...(|) + backspace
    ...|
  • the set of pairs is configurable

Installation

  • Using Fisher:

    fisher add laughedelic/pisces
  • Using oh-my-fish:

    omf install pisces

NOTE:
The minimum recommended version of fish is v2.6, because

  • it has a feature called bracketed (a.k.a safe) paste which solves the problem with pasting strings containing paired symbols (they get autoclosed), see #6 for details.

The minimum required version of fish is v2.3, because

  • there was a bug #2210 in v2.2 which would brake quotes handling
  • it uses string builtin which was introduced in v2.3

Changing the set of pairs

You can set the $pisces_pairs universal variable and launch a new fish session to reload key bindings:

set -U pisces_pairs $pisces_pairs '<,>' '`,`' '«,»'

Note that at the moment pisces works correctly only with single-symbol delimiters.

The default set of pairs:

  • (,) parenthesis
  • [,] brackets
  • {,} braces
  • "," double quotes
  • ',' single quotes

Roadmap

Here are some ideas for further development (some are already implemented):

  • autoclosing:

    • ignore closing " when trying to autocomplete a var (see v0.3.0)
    • #5 (WIP): context-dependent autoclosing. Some particular cases:
      • ? autoclose only when surrounded by non-word characters
      • ignore escaped symbols: ...\| + ( => ...\(| (or autoclose them?)
      • ? ignore single quote (apostrophe) in the comments
      • multi-character pairs, similar to simple code-snippets: for | end, if | end, begin; |; end, etc.
  • empty pairs removal:

    • treat pair as empty if it has only whitespaces inside: ...(| ) + backspace...|
    • remove an empty pair even when the cursor is after it (or go inside?): ...()| + backspace...| or ...(|) (this is probably confusing)
    • key bindings for ^W and similar? foo bar(|) + ctrlwfoo |
  • optional alt+symbol keybindings that do something else, for example:

    • surround the current token
    • just insert single symbol
    • jump after the closing symbol
  • #3: support for vi-mode

  • autoreload on the $pisces_pairs var changes

  • restore previous keybindings instead of erasing them

If you have any other ideas or feature requests, feel free to open an issue or just write me in the chat.

About

♓️ Fish shell plugin that helps you to work with paired symbols in the command line

License:Other


Languages

Language:Shell 100.0%