1
0
hugo/content/blog/2017-05-05-git.md
2024-04-23 22:21:26 +09:00

55 lines
1.2 KiB
Markdown

+++
date = "2017-05-05"
tags = ["git"]
title = "git-sh"
slug = "git"
+++
gitshというものがあるのですが、zshではそれを使わなくても以下のような感じでいけます。
https://github.com/thoughtbot/gitsh
http://pocke.hatenablog.com/entry/2015/12/09/000000
```bash
function git-sh()
{
eval "__precmd_for_git-sh() { print -z '$* ' }"
autoload -Uz add-zsh-hook
add-zsh-hook precmd "__precmd_for_git-sh"
}
```
```bash
$ git-sh git
$ git status
```
ただ、注意点としてはzshでは`x-x`という形式だと空白でもコマンドを発行できるので、思わぬ結果を招くことも。
> /path/to/git-ci
```bash
git commit -m "$*"
```
上記は、こんな感じで便利に使える場合もあります。
```bash
# git commit -m "add : commit message!"
# ↓
$ git ci add : commit message!
```
ちなみに`fish`やるなら以下のような感じ。`--description`は補完に使う事が多い。但し、そのままでは使えない。
```bash
function git --description 'ci'
if test (count $argv) -ge 2
git commit -m "$argv[2..-1]"
end
end
```
というか、今度、特定のタグがついた時、本サイトのまとめ記事に追加する仕組み作ろう...。