小编Cal*_*leb的帖子

在 zsh 提示符下 git commit hash

我想在 zsh 提示符中查看当前提交哈希(仅前 8 个字符)。

到目前为止我有这个:https://github.com/calebmeyer/cpm-zsh-theme/blob/master/cpm.zsh-theme#L3

git_commit_hash() {
  if [ -d .git ]; then
    git log -1 --pretty=oneline | cut -c -8
  fi
}
Run Code Online (Sandbox Code Playgroud)

当我获取文件时(通过. ./cpm.zsh-theme),我看到当前提交的提交哈希。但是,当我更改目录或进行更改/提交时,它不会更新。这也意味着当我在提示启动时加载主题时,没有提交哈希(并且永远不会更新)

这是一个屏幕截图:我的提示!

如何让 zsh 在每个新提示时重新评估此函数?

注意:我使用 oh-my-zsh 和抗原来管理我的配置。您可以在这里看到我的点文件:https ://github.com/calebmeyer/dotfiles

zsh git command-line prompt

5
推荐指数
1
解决办法
2183
查看次数

标签 统计

command-line ×1

git ×1

prompt ×1

zsh ×1