For more information on the command line for Git from Zsh

Torvalds seems to have the following invitation .

[torvalds@g5 git]$ 

The first word is the username. g5It seems to be a branch in Git repo, but gitshows that it is a branch in Git.

My current invitation

PROMPT="$"

How can you get a similar invitation like Torvalds?

0
source share
6 answers

Actually, I assume that it g5refers to the host name of the machine on which it is currently running, and gitis the current working directory. The format [user@hostname dir]$is a fairly standard (i.e. widely used) shell prompt.

+4

Git Bash __git_ps1.

PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' ( .bashrc ) , :

[user@host ~]$ cd /usr/src/linux
[user@host linux ((v2.6.30))]$
+3

zsh ( bash), VCS Xana Yammering vcs_info, zsh, Git.

+2

, , Git bash script , . Github . , , git. , , : blaenk@macbook:~ $, , git: blaenk@macbook:~/code/iphone/DIFM (master*)$

, , , , . , ; +, . . GIT_PS1_SHOWSTASHSTATE . , , ~/.bashrc ~/.bash_profile, :

export GIT_PS1_SHOWDIRTYSTATE=true

, git, , - - . , . . , :

git checkout -- the/file.txt

, bash script . , , - "git chec", TAB, , , , .

, , , , : , , , , , . .

+1

. .

" " zsh, git git .

0

 function get_git_branch { 
   git branch | awk '/^\*/ { print $2 }
 }
 function get_git_dirty { 
   git diff --quiet || echo '*'
 }
 function get_git_prompt { 
   git branch &> /dev/null || return 1 
   echo "($(get_git_branch)$(get_git_dirty)) "
 }
 PROMPT="$(get_git_prompt)\$ "

-1

Source: https://habr.com/ru/post/1712696/


All Articles