Giter Club home page Giter Club logo

zsh-prompt-garrett's Introduction

Garrett Zsh Theme for Prezto

A prompt with the information you need the moment you need it.

NEW: It's been a long time coming but I've added gifs so you can see what the fuss is all about!

I designed my prompt for readability and to present useful information when needed.

The Garrett prompt supports:

  • git status information
  • All prompt types (PS1-PS4, Autocorrection, and a backup SUDO_PS1)
  • Notification of background jobs
  • Non-zero return codes
  • Line drawing
  • ssh status
  • Directory truncation
  • Vi-editor info
  • Job completion
  • History line number
  • The current time

Prompt types

Standard Prompt (PS1)

Many (most?) prompts put the directory information in front of the cursor entry point. Changing directories changes the location of the cursor on the screen. This inconsistent location is undesirable. The Garrett prompt cursor is consistently at the same place on the screen.

By using line drawing and inserting a newline between each command, scrolling back through your history for the output of a previous command becomes drastically easier.

Both Terminal and iTerm2 support line drawing and the prompt will look it's best there.

The Garrett prompt has a fallback if line drawing is unsupported by your terminal emulator.

The terminal theme shown here is Solarized Dark and the font is Pragmata Pro (affiliate link).

Right Prompt (RPROMPT)

The right prompt contains useful information but moves out of the way for long commands.

Continuation prompt (PS2)

Selection prompt (PS3)

NOTE: This view contains both the selection and continuation prompts. The selection prompt is shown when entering 1, 2, or 3.

Execution trace prompt (PS4)

Autocorrection prompt

Backup root prompt

There is a backup root prompt that will highlight most of the terminal in red if you switch to the sudo user inside another shell which hasn't set this prompt. It's a simple safety measure.

NOTE: This feature is available only when the shell environment is not reset by switching to the sudo command. i.e., switch to root using sudo -s and you will see the prompt change its primary color to red (as described above); switch to root with sudo -i, the environment will be reset and you'll see the base Zsh prompt instead of my custom one.

Features

This prompt has the following features. These features may be disabled and rearranged as desired by using the corresponding tokens. There are also minor changes that can (easily) be made in terms of formatting the output of the prompt by editing the prompt file itself but that's up to you.

Change host color when on ssh

You can display either the full or truncated hostname on ssh by editing the prompt file. The default is to display the truncated hostname.

NOTE: The primary prompt color changes from gray to orange—color was lost when making the gif (#1).

Change prompt color when UID is root

As a safety feature, the prompt will change color when logged in as the root user. This looks the same as host color change on ssh but with a red color instead of orange.

ls the directory contents on cd

Determine the number of background jobs

Present working directory truncation, if needed

Directory truncation will slim down the PWD to the first letter of each child directory. This is configurable via Prezto.

Report non-zero return codes

Support for non-zero return codes must be enabled. See Prezto's prompt documentation.

Report local time

You can change to time format from within the prompt file. Available options:

  • 24 hour time format (default)
  • 24 hour time format, second precise
  • AM/PM time format

Report the terminal line number

Useful for bang history completion and hipster pride.

Report git status, git remote status, git prompt info and git SHA information

Symbol Meaning
λ:master branch
9769ee9 commit hash
| dirty
ahead
behind
diverged
stashed
added
deleted
modified
renamed
unmerged
untracked

Indicate vi-mode

Normal mode:

Overwrite mode:

If you like, you can add notification of insert mode by editing the prompt.

Notifications for commands taking longer than n seconds

The default time is 2 seconds but is adjustable in the code.

Installation

  • Have a working installation of Prezto
  • Copy prompt_garrett_setup to ~/.zprezto/modules/prompt/functions/
  • Set zstyle ':prezto:module:prompt' theme 'garrett' in ~/.zpreztorc
  • Optionally, configure pwd trunctation
  • Open a new terminal window

If you'd rather not have to do this, please provide your support on Prezto #914.

Helpful tips

Here's helpful suggestions and tips for ensuring the prompt works at its best.

Like it?

If you've found this project useful, would you consider sending your support?

Author

The author of this module should be contacted via the issue tracker.

Chauncey Garrett

zsh-prompt-garrett's People

Contributors

cbowns avatar chauncey-garrett avatar jef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zsh-prompt-garrett's Issues

Broken pipe

prompt_garrett_preprompt_render:print:21: write error: broken pipe
prompt_garrett_preprompt_render:21: write error: broken pipe

spotted when I run my .zshrc with zprof

Investigate merging most of chauncey-garrett/prezto back into upstream

I've been looking at your fork since I ran across sorin-ionescu/prezto#914 and I was hoping to merge some of these changes back upstream as well as adding some of the new modules to the upcoming contrib repo.

Sorry for filing in your prompt repo but your prezto fork has issues disabled.

  1. Editor changes: sorin-ionescu/prezto@master...chauncey-garrett:master#diff-d47aedeec385fb4b85ecd505c23f9572
    These seem useful. One thing I'm not quite as sure about - I feel like the last block shouldn't set editor_info[overwrite] at all, unless I'm misunderstanding something. (I'm planning on committing these changes soon, if you don't have any objections)
  2. Don't display rbenv version if using system - I've already merged a similar version upstream in sorin-ionescu/prezto@c7dcd21
  3. General improvements to the utility module
    Most of this seems useful, though I don't understand the mnemonic for lld and lsd.
    I'd be happy to upstream this once those aliases are figured out.
  4. The garrett prompt - this is one of the better multi-line prompts I've seen and I'd love to have a way of including it... unfortunately we're in the middle of adding a contrib repo where we'd probably include most external modules. Once that's in, I would definitely be willing to include it in some sort of prompt-contrib module (We're hoping to move most themes to there, rather than including them in prezto-core) and might even be willing to include it directly in core eventually, given how good you've been about keeping your repos up to date.
  5. Your additional external modules - these would also be good fits for the contrib repo when it's ready

Please let me know if you have any thoughts on this. It would be great to get your opinion on some of the upcoming prezto changes because you seem to keep this prompt and your prezto pretty up to date.

Root color issue on Ubuntu

Hi,
I get [\e[31;1;46m][\u] \w $[\e[0m] instead of colored root when sudoing.
Using zsh version 5.0.2 on Ubuntu 14.04.

Continuation Prompt is incomplete

I've just installed prompt and noticed that the continuation prompt is incomplete. Using the example, I'm not seeing (for) in the prompt:

┌─( ~ )────────────────────────────────────────────────────────────────────────────────────( @macbook-pro )─┐
└─❱❱❱ for i in {1..10} 1 ⏎ +106 17:31 ❰─┘
() ❱❱❱

Is this a configurable option, or is there a problem with my install?

Please add a license and a screen shot

Please add a screen shot so that users can see what the theme looks like without having to install it.

Also, please add a license file, some people won't use any code that doesn't have an open source license. If you don't have one in mind, https://choosealicense.com is a good resource to help you select an appropriate one.

Thanks!

Can't get the right prompts to display properly

After updating Prezto and re-installing the Garrett prompt (by copying the prompt_garrett_setup file into my ~/.zpreztorc/modules/prompt/functions directory) and editing the zstyle ':prezto:module:prompt' theme 'garrett' line in zpreztorc) the two prompts on the right-hand side are not displaying correctly.

Screen Shot 2020-04-05 at 5 09 07 PM

The top line shows the computer name as expected, but also the history line number and current time. Meanwhile, the bottom line shows nothing, including the little arrow.

This seems similar to #11 except that I'm on a Mac OSX 10.5.4 using iTerm2 3.3.9. Thank you for your help.

Definition of prompt #

2017-07-29 19_30_56-bash

Hi Garrett,

Can you help me understand what the ( 3 ) is in the screen shot above. Its not reference in the docs, and not clear to be from the code.

Not compatible with donnemartin/gitsome

Try using this prompt with https://github.com/donnemartin/gitsome

Unfortunately it breaks the xonsh shell invoked by gitsome:

┌─( ~/.homesick/repos/prezto ⬆  master M e434b0a )──────────────────────────────( node:6.2.2 @3n )─┐
└─❱❱❱ gitsome                                                                         +5647 9:25 ❰─┘
Version: 0.6.0
xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
KeyError: 'prompt_garrett_color_prompt'
${prompt_garrett_altchar_enable}${prompt_garrett_color_prompt}${prompt_garrett_lower_left_corner}${ed
itor_info[keymap]}exit


┌─( ~/.homesick/repos/prezto ⬆  master M e434b0a )──────────────────────────────( node:6.2.2 @3n )─┐
└─❱❱❱                                                                                 +5647 9:25 ❰─┘

Any idea why?

Color issue on Centos 7?

Nice theme! :)

This is how it looks while installed on a Centos 7.1 machine and ssh'ing in via iTerm2 (osx yosemite). Something I've missed?

skarmavbild 2015-07-17 kl 15 48 39

Posh Git

Firstly, hands down my favourite theme 👍

However, I'd like to replace the Prezto git info with Posh Git. My zsh is limited, no joy. Please can you help?

Virtual Environments

Hi,

I noticed that if I access a virtual environment through either conda or virtualenvwrapper, the name of the environment is prepended to the left square bracket like so. Is it possible to move that into either the bottom left parentheses or the top right?

term

PS1 line drawing in iTerm2 howto

This is what worked for me, both in iTerm2

Goto your iTerm2/3 Preferences -> Profiles -> Terminal -> Terminal Emulation ->

  • Character Encoding:
    Set to 'Unicode (UTF-8)'
  • Report Terminal Type:
    Set to 'xterm-256color'

Keep path visible after clearing the screen

If you run clear command, both lines of prompt stay visible on top of the screen.
However, when the clear command is run with Ctrl + L, only the second line with arrows is visible, so you effectively lose track of where you are in your directory structure.

Ubuntu 14.04.

Drawing issues on FreeBSD

Hi! I just installed your theme, as explained in the README. However, the fallback looks like this:
capture du 2017-10-17 17-54-06

And it quite hurts the eye after 20s :/
Do you know what's happening here so I may help?

Can't get the prompt to display properly (❱❱❱)

I edited this part:

if (( $SHLVL == 1 )); then
    export PROMPT='${prompt_garrett_altchar_enable}${prompt_garrett_color_prompt}${prompt_garrett_lower_left_corner}${editor_info[keymap]}'

and put some ❱❱❱ at the end and it works:

image

But for whatever reason, the

zstyle ':prezto:module:editor:info:keymap:primary' format "${red}❱%(?.${prompt_garrett_color_prompt}.${red})❱❱ "

isn't working on the default.

image

Could be relevant to sorin-ionescu/prezto#965, but even with those changes, it doesn't work :/

I also cleared all my preferences on iTerm2 and Terminal with a reinstall of zsh just to rule out any funny locale business. Keymap on macOS is English (US).

$ locale

LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=

Strange enough, I'm getting my RPROMPT though...

image

Issues on FreeBSD

FreeBSD 11.1 Stable
Parallels 13 for Apple Mac
macOS 10.13.3 High Sierra

Hello, following on from issue #23, I too am having issues with FreeBSD. This is what my terminal currently looks like:

screen shot 2018-03-23 at 03 29 21

The fact that the font name is showing up in the preferences suggests that the OS is recognising the font. It's just not displaying the characters very well.

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.