使用Git信息自定义ZSH提示

时间:2020-08-02 13:58:03

标签: zsh

我有这段代码来显示我正在〜/ .zshrc下工作的git分支

# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }

#colors
PROMPT="%F{15}%n%f@%F{228}%m%f:%F{87}%d%f ${vcs_info_msg_0_} -> "

但是如果文件夹是git repo,它不会自动检测文件夹,每次zshrc文件时都需要提供源文件

sshkilevich@pro-3111:/Users/sshkilevich/python-Projects/django/rest-api  -> ll
total 520
drwxr-xr-x  17 sshkilevich  staff     544 Aug  2 16:17 .
drwxr-xr-x   4 sshkilevich  staff     128 Aug  2 10:12 ..
drwxr-xr-x  12 sshkilevich  staff     384 Aug  2 16:11 .git
-rw-r--r--   1 sshkilevich  staff      67 Aug  2 11:15 .gitignore
drwxr-xr-x   9 sshkilevich  staff     288 Aug  2 16:09 .idea
drwxr-xr-x   4 sshkilevich  staff     128 Jul 30 17:28 .vagrant
-rw-r--r--   1 sshkilevich  staff       8 Jul 30 15:02 LICENSE
-rw-r--r--   1 sshkilevich  staff      54 Jul 30 13:46 README.md
-rw-r--r--@  1 sshkilevich  staff    1188 Aug  2 10:11 Vagrantfile
-rw-r--r--   1 sshkilevich  staff  143360 Aug  2 16:17 db.sqlite3
drwxr-xr-x   5 sshkilevich  staff     160 Aug  2 10:49 django-app-env
-rwxrwxr-x   1 sshkilevich  staff     636 Aug  2 10:39 manage.py
drwxr-xr-x  10 sshkilevich  staff     320 Aug  2 15:16 profiles_api
drwxr-xr-x   7 sshkilevich  staff     224 Aug  2 16:06 profiles_project
-rw-r--r--   1 sshkilevich  staff     130 Aug  2 11:01 requirements.txt
-rw-r--r--   1 sshkilevich  staff      14 Jul 30 18:50 script.py
-rw-------   1 sshkilevich  staff   38394 Aug  2 10:19 ubuntu-bionic-18.04-cloudimg-console.log
sshkilevich@pro-3111:/Users/sshkilevich/python-Projects/django/rest-api  -> source ~/.zshrc
sshkilevich@pro-3111:/Users/sshkilevich/python-Projects/django/rest-api  (git)-[master]- ->

我在这里想念什么? ps-处理本文link

0 个答案:

没有答案