Git Product home page Git Product logo

prompt-pwd's Introduction

prompt-pwd

Formats the path to the current working directory to be used by prompts.

Settings

Use the following zstyle to truncate the path to the git root when in a git repo:

zstyle ':zim:prompt-pwd' git-root yes

To truncate the number of trailing path components, use the following zstyle with a positive value:

zstyle ':zim:prompt-pwd:tail' length <value>

To customize the maximum number of characters per path component, use:

zstyle ':zim:prompt-pwd:fish-style' dir-length <value>

Setting the value to 0 will disable shortening entirely, which is the default behavior.

The default path separator is / and it can be customized using:

zstyle ':zim:prompt-pwd:separator' format '<format>'

You can include prompt expansion escape sequences in your custom separator format.

Theming

Add a call to the prompt-pwd function in your prompt code where you want the current working directory to be displayed. Here's an example:

setopt nopromptbang prompt{cr,percent,sp,subst}

zstyle ':zim:prompt-pwd' git-root yes
zstyle ':zim:prompt-pwd:fish-style' dir-length 1
zstyle ':zim:prompt-pwd:separator' format ''

PS1='$(prompt-pwd)❯ '

If you want to use prompt-pwd inside a function, call it passing the variable name you want it to set. A dummy example:

prompt-pwd-len() {
  local current_dir
  prompt-pwd current_dir
  print ${#current_dir}
}

prompt-pwd's People

Contributors

ericbn avatar

Stargazers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.