Giter Site home page Giter Site logo

lean's Introduction

About

After having used prompt pure for about a year, I felt that a two-line prompt was not for me. Also not utilizing the right side of the terminal seemed a missed opportunity. Still there is much to like: the elapsed time of a process, the coloring of the prompt if the exit code of the process isn't 0, git integration. So I took "pure", mixed in my ideas of what a prompt should look like and came up with "lean" - a 1 line prompt that stays out of your face.

When lean starts, only 2 characters show on the screen '%' on the left and '~' on the right.

lean example gif

So lean is an evolution of pure, with the following changes:

  • Defaults to a very sparse setup, only showing information you need at the moment.
  • Comes with the perfect prompt character. Author went through the entire ASCII range to find it (and found it pretty quickly!)
  • Never displays your username (assuming you know who you are).
  • When tmux is active it shows a yellow 't' (I disabled the tmux bar, so this is some visual indication that tmux is active). If you don't want this indicator, you can always set PROMPT_LEAN_TMUX="" prior to loading this plugin (or prior to sourcing zgen, etc.).
  • Show remote host if logged in through SSH.
  • All in one line, most stuff in the right prompt, leaving the left prompt nice and clean
  • Shows background jobs (in the left prompt)
  • Show (dirty) git repos (can be disabled by setting PROMPT_LEAN_VCS to 0). The branch name is truncated to 20 characters.
  • Shortens path if needed (longer then 70% of your screen). Two methods are provided: 'truncate' and 'shrink' (fish-style working directory). Set PROMPT_LEAN_ABBR_METHOD to choose the one you like the most (default is 'truncate'). Set PROMPT_LEAN_PWD to 0 to disable showing the path altogether.
  • Uses PROMPT_LEAN_LEFT and PROMPT_LEAN_RIGHT to allow customization of the left and/or right side of the prompt.
  • For a configurable insert-mode indicator, set the PROMPT_LEAN_VIMODE and PROMPT_LEAN_VIMODE_FORMAT variables. PROMPT_LEAN_VIMODE_FORMAT defaults to "%F{red}[NORMAL]%f"
  • Configurable colors to match your preferred scheme, by setting PROMPT_LEAN_COLOR1 and PROMPT_LEAN_COLOR2
  • Use PROMPT_LEAN_NOTITLE to customize when the title should not be displayed. Useful for terminals that can not show title properly.
  • Use PROMPT_LEAN_VCS and PROMPT_LEAN_PWD to disable showing VCS info or the current working directory.

Installation

zgen

If you use zgen you can add the following to your ~/.zshrc:

zgen load miekg/lean

and force reload with zgen reset && source ~/.zshrc.

Note you must have the option PROMPT_SUBST set, see zshoptions(1).

prezto

If you use prezto you should do the following:

cd $ZPREZTODIR && git clone --recurse-submodules https://github.com/belak/prezto-contrib contrib

Then in ~/.zpreztorc add contrib-prompt to module load list and select lean as a theme:

zstyle ':prezto:load' pmodule \
  ... \
  'contrib-prompt' \
  'prompt' \
  ...

zstyle ':prezto:module:prompt' theme 'lean'

PROMPT_LEAN_LEFT and PROMPT_LEAN_RIGHT should be customized in ~/.zshrc. The rest variables should be customized in ~/.zshenv.

Development

If you make any changes please run make test to ensure the (little) test suite is succesfull.

lean's People

Contributors

derverrucktefuchs avatar dne avatar doomhammer avatar ericbn avatar erickpintor avatar f440 avatar gilbertw1 avatar hit0ri avatar jmkk avatar miekg avatar mikybars avatar sergiorussia avatar sqve avatar tomfitzhenry avatar valinora avatar yujishen avatar yvkschaefer 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  avatar  avatar  avatar  avatar  avatar  avatar

lean's Issues

Hello

I am a chinese students.

Use `typeset -g` for global variables in functions

See sindresorhus/pure#345

Please use declare -g ( or typeset -g, it's the same) to declaring global variables in functions. So, people who set setopt WARN_CREATE_GLOBAL won't get warning like such:

prompt_lean_precmd:19: scalar parameter prompt_lean_vimode created globally in function prompt_lean_precmd                                                              
prompt_lean_cmd_exec_time:4: scalar parameter PROMPT_LEAN_CMD_MAX_EXEC_TIME created globally in function prompt_lean_cmd_exec_time

Reproduction steps: Wrote setopt WARN_CREATE_GLOBAL in .zshrc.

Right side of prompt disappearing on smaller terminals

Thanks for the awesome prompt, better and lighter than pure! โค๏ธ

So the right side of the prompt disappears when we have smaller screens, I know that this is probably the right behavior but there is a way to make it not happen? ๐Ÿ˜…

A ENV variable, or maybe point me things I could do in the code to make this happen?

Thanks again! ๐Ÿ˜„

Install theme

Hi.
I'm new at zsh, could you add how to install your theme in the README?

new to this; trying to set environment variables?

Hey there! I'm using lean with zim, and I'm trying to figure out where and how to set the PROMPT_LEAN-prefixed environment variables.

Also, I don't know if vimode was supposed to automatically be registered, but whenever I enter vimode nothing happens on the prompt.

For reference, I'm using:
Mac OSX
iTerm2
zsh
tmux

everything else works fine (t shows up when tmux is active, seconds are registered, git shows up).

Thanks for your help!

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.

From zimfw/zimfw#110 since it seems to be an issue with this prompt.


When using the lean prompt, and trying to create a new local git repo using git init, there is the following error

% git init
Initialized empty Git repository in /home/brott/Desktop/testgit/.git/
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.                                               
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Related info

space after prompt

For some reason the terminal version (at least for gnome-terminal) either eats or does not eat the space after the terminal prompt. The lastest push added an explicit space, but this now has the effect of having two space when logging in remotely.

Need to test terminals and provide a work around.

make coloring configurable

I've changed my shell/terminal/vi colours and I'm going to change the default in this repo. Would be nice to have some kind of setup where the colours can be defined at the top of the file. Currently it's all embedded in the PROMPT and RPROMPT defs.

Extra text under Emacs ansi-term

Under Emacs (Spacemacs) ansi-term, I will get some extra text before actual result.
For example:

% cd ~
0;Downloads: cd ~%
% ls
0;Yuji: gls --color=tty Applications Desktop Documents

These texts will not show if I enter /bin/bash under ansi-term.

I am not sure what causes this problem... Is lean, or oh-my-zsh or zsh, or emacs?

Prints part of sed command

Thank you for an awesome prompt! ๐Ÿ™

I noted today when going ham on some sed scripts that I was getting strange outputs. After quite a bit of trail and error I was able to point out lean as the culprit.

When I run the following command: echo "foo" | sed -r 's/(foo)/\1bar/' is outputs bar/'foobar which is incorrect. It seems like it's having problems as soon as I use sed groups.

# Problematic command in lean prompt.
% echo "foo" | sed -r 's/(foo)/\1bar/'
bar/'foobar

# Change to pure prompt.
% sed -i 's/lean/pure/' .dotfiles/zimrc && zsh

# Sed command works in pure prompt.
โฏ echo "foo" | sed -r 's/(foo)/\1bar/'
foobar

# Also works in bash.
โฏ bash
[sqve@boh ~]$ echo "foo" | sed -r 's/(foo)/\1bar/'
foobar

Give me a ping if I can help out and provide any more information.

Black background around the prompt symbol after a failed command

As you can see on this screenshot, there's a black background around the prompt symbol after a command terminated with a non-0 exit code, while when it's 0 it matches the terminal's background. I don't know if it's intended, but can it be changed somewhere?
wrong_colours

PS: I really enjoy your theme, thanks for having shared it.

screencast missing

The page states:

This recording has been archived
All unclaimed recordings (the ones not linked to any user account) are automatically archived 7 days after upload.

Failure to output content without newline

% zsh -f
moro% cat JUNK
Testing%
moro% exit
% cat JUNK
%

First create a file with the content Testing without a newline. Run zsh -f or bash and then cat that file to output content. Exit back to zim configured zsh and run cat again.

See zimfw/zimfw#209

some fails when i source the prompt_lean-test.zsh

% source prompt_lean_test.zsh                                                        ~/code/source/lean$vcs_info_msg_0_
  OK - prompt
FAIL - rprompt
00000000  25 46 7b 79 65 6c 6c 6f  77 7d 25 66 25 46 7b 31  |%F{yellow}%f%F{1|
00000010  34 30 7d 2f 74 6d 70 25  46 7b 32 34 31 7d 24 76  |40}/tmp%F{241}$v|
00000020  63 73 5f 69 6e 66 6f 5f  6d 73 67 5f 30 5f 25 66  |cs_info_msg_0_%f|
00000030  25 66 0a                                          |%f.|
00000033
00000000  25 46 7b 79 65 6c 6c 6f  77 7d 25 66 25 46 7b 31  |%F{yellow}%f%F{1|
00000010  34 30 7d 2f 74 6d 70 25  46 7b 32 34 31 7d 24 76  |40}/tmp%F{241}$v|
00000020  63 73 5f 69 6e 66 6f 5f  6d 73 67 5f 30 5f 20 25  |cs_info_msg_0_ %|
00000030  46 7b 79 65 6c 6c 6f 77  7d 25 6d 25 66 25 66 25  |F{yellow}%m%f%f%|
00000040  66 0a                                             |f.|
00000042
  OK - lean_left
FAIL - lean_right
00000000  25 46 7b 79 65 6c 6c 6f  77 7d 25 66 25 46 7b 31  |%F{yellow}%f%F{1|
00000010  34 30 7d 2f 74 6d 70 25  46 7b 32 34 31 7d 24 76  |40}/tmp%F{241}$v|
00000020  63 73 5f 69 6e 66 6f 5f  6d 73 67 5f 30 5f 25 66  |cs_info_msg_0_%f|
00000030  72 69 67 68 74 25 66 0a                           |right%f.|
00000038
00000000  25 46 7b 79 65 6c 6c 6f  77 7d 25 66 25 46 7b 31  |%F{yellow}%f%F{1|
00000010  34 30 7d 2f 74 6d 70 25  46 7b 32 34 31 7d 24 76  |40}/tmp%F{241}$v|
00000020  63 73 5f 69 6e 66 6f 5f  6d 73 67 5f 30 5f 20 25  |cs_info_msg_0_ %|
00000030  46 7b 79 65 6c 6c 6f 77  7d 25 6d 25 66 25 66 72  |F{yellow}%m%f%fr|
00000040  69 67 68 74 25 66 0a                              |ight%f.|
00000047
  OK - tmux
FAIL - time
00000000  25 46 7b 79 65 6c 6c 6f  77 7d 31 73 20 25 66 25  |%F{yellow}1s %f%|
00000010  46 7b 31 34 30 7d 2f 74  6d 70 25 46 7b 32 34 31  |F{140}/tmp%F{241|
00000020  7d 24 76 63 73 5f 69 6e  66 6f 5f 6d 73 67 5f 30  |}$vcs_info_msg_0|
00000030  5f 25 66 25 66 0a                                 |_%f%f.|
00000036
00000000  25 46 7b 79 65 6c 6c 6f  77 7d 31 73 20 25 66 25  |%F{yellow}1s %f%|
00000010  46 7b 31 34 30 7d 2f 74  6d 70 25 46 7b 32 34 31  |F{140}/tmp%F{241|
00000020  7d 24 76 63 73 5f 69 6e  66 6f 5f 6d 73 67 5f 30  |}$vcs_info_msg_0|
00000030  5f 20 25 46 7b 79 65 6c  6c 6f 77 7d 25 6d 25 66  |_ %F{yellow}%m%f|
00000040  25 66 25 66 0a                                    |%f%f.|
00000045

Small triangle before % in iTerm

There is a small triangle before the "%" when I use iTerm. It is perfect normal when I user Terminal. Is this a problem with the theme or iTerm?
2017-02-02_22-12-34 1

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.