美文网首页
oh my zsh prompt 展示当前路径

oh my zsh prompt 展示当前路径

作者: yxibng | 来源:发表于2020-11-21 10:56 被阅读0次

    使用的主题为

    ZSH_THEME="robbyrussell"
    

    操作前

    ➜  Desktop cd Audio-mac
    ➜  Audio-mac git:(master)
    

    操作后

    ➜  /Users/yxibng/Desktop cd Audio-mac
    ➜  /Users/yxibng/Desktop/Audio-mac git:(master)
    

    方法, 打开

    ➜  ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
    

    %c替换为%d

    PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
    
    PROMPT+=' %{$fg[cyan]%}%d%{$reset_color%} $(git_prompt_info)'
    

    参考:EXPANSION_OF_PROMPT_SEQUENCES

    Shell state

    %#
    A `#' if the shell is running with privileges, a `%' if not. Equivalent to `%(!.#.%%)'. The definition of `privileged', for these purposes, is that either the effective user ID is zero, or, if POSIX.1e capabilities are supported, that at least one capability is raised in either the Effective or Inheritable capability vectors.
    
    %?
    The return status of the last command executed just before the prompt.
    
    %_
    The status of the parser, i.e. the shell constructs (like `if' and `for') that have been started on the command line. If given an integer number that many strings will be printed; zero or negative or no integer means print as many as there are. This is most useful in prompts PS2 for continuation lines and PS4 for debugging with the XTRACE option; in the latter case it will also work non-interactively.
    
    %^
    The status of the parser in reverse. This is the same as `%_' other than the order of strings. It is often used in RPS2.
    
    %d%/
    Current working directory. If an integer follows the `%', it specifies a number of trailing components of the current working directory to show; zero means the whole path. A negative integer specifies leading components, i.e. %-1d specifies the first component.
    
    %~
    As %d and %/, but if the current working directory starts with $HOME, that part is replaced by a `~'. Furthermore, if it has a named directory as its prefix, that part is replaced by a `~' followed by the name of the directory, but only if the result is shorter than the full path; see Dynamic and Static named directories in zshexpn(1).
    
    %e
    Evaluation depth of the current sourced file, shell function, or eval. This is incremented or decremented every time the value of %N is set or reverted to a previous value, respectively. This is most useful for debugging as part of $PS4.
    
    %h%!
    Current history event number.
    
    %i
    The line number currently being executed in the script, sourced file, or shell function given by %N. This is most useful for debugging as part of $PS4.
    
    %I
    The line number currently being executed in the file %x. This is similar to %i, but the line number is always a line number in the file where the code was defined, even if the code is a shell function.
    
    %j
    The number of jobs.
    
    %L
    The current value of $SHLVL.
    
    %N
    The name of the script, sourced file, or shell function that zsh is currently executing, whichever was started most recently. If there is none, this is equivalent to the parameter $0. An integer may follow the `%' to specify a number of trailing path components to show; zero means the full path. A negative integer specifies leading components.
    
    %x
    The name of the file containing the source code currently being executed. This behaves as %N except that function and eval command names are not shown, instead the file where they were defined.
    
    %c%.%C
    Trailing component of the current working directory. An integer may follow the `%' to get more than one component. Unless `%C' is used, tilde contraction is performed first. These are deprecated as %c and %C are equivalent to %1~ and %1/, respectively, while explicit positive integers have the same effect as for the latter two sequences.
    

    相关文章

      网友评论

          本文标题:oh my zsh prompt 展示当前路径

          本文链接:https://www.haomeiwen.com/subject/wdbsiktx.html