https://github.com/knu/zsh-git-escape-magic
zle tweak for git command line arguments
https://github.com/knu/zsh-git-escape-magic
Last synced: 11 months ago
JSON representation
zle tweak for git command line arguments
- Host: GitHub
- URL: https://github.com/knu/zsh-git-escape-magic
- Owner: knu
- License: bsd-2-clause
- Created: 2011-05-26T20:30:09.000Z (about 15 years ago)
- Default Branch: main
- Last Pushed: 2024-09-11T09:15:43.000Z (almost 2 years ago)
- Last Synced: 2025-04-06T22:02:48.924Z (about 1 year ago)
- Homepage:
- Size: 7.81 KB
- Stars: 73
- Watchers: 8
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
git-escape-magic for zsh
========================
Synopsis
--------
* git-escape-magic - zle tweak for git command line arguments
Description
-----------
If you are a hard-core zsh user that takes `extended_glob` seriously
for granted, you must be annoyed with git's refspec (notation to point
a commit, tree, etc.) that goes like `HEAD^` or `blahblah~3` because
the signs like `[^~{}]` are globbing meta-characters for zsh that
require escaping to be passed through to the git command.
Here is what this tweak is about. It eliminates the need for manually
escaping those meta-characters. The zle function it provides is
context aware and recognizes the characteristics of each subcommand of
git. Every time you type one of these meta-characters on a git
command line, it automatically escapes the meta-character with a
backslash as necessary and as appropriate.
Examples:
% git reset HEAD [Hit <^>]
% git reset HEAD\^
# Escaping takes place only if necessary
% git reset HEAD\ [Hit <^>]
% git reset HEAD\^
% git reset HEAD@ [Hit <{>]
% git reset HEAD@\{
% git checkout HEAD [Hit <~>]
% git checkout HEAD\~
# Only pathspec follows after a double hyphen
% git checkout -- * [Hit <~>]
% git checkout -- *~
# The add subcommand takes no refspec
% git add * [Hit <~>]
% git add *~
How to set up
-------------
Put the file `git-escape-magic` somewhere in your `$fpath` and add
these lines to your `.zshrc`:
autoload -Uz git-escape-magic
git-escape-magic
If you are enabling `url-quote-magic`, make sure to load it first and
then load `git-escape-magic`.
License
-------
Copyright (c) 2011, 2012, 2014 Akinori MUSHA
Licensed under the 2-clause BSD license.
See `LICENSE` for details.