Commit Graph

283 Commits (abomination)

Author SHA1 Message Date
Felix bc8ffae08c Fix path trimming and line break 2018-10-15 19:58:49 +02:00
Felix 5cf4e21b03 save changes 2018-10-15 19:58:49 +02:00
Felix 2aa3245b50 Fix dirtrim, tabs 2018-10-15 19:58:49 +02:00
Felix ff1d7aa14d Add dir trim function 2018-10-15 19:58:49 +02:00
Felix 64ca0e92f0 Add exit code to red prompt 2018-10-15 19:58:49 +02:00
Felix 26b1477379 Change git dirty symbol 2018-10-15 19:58:49 +02:00
Felix c16e45c7b6 Break prompt over two lines when it gets too long 2018-10-15 19:58:49 +02:00
Felix f8a7c90beb Set git_color to turquoise and virtualenv to blue 2018-10-15 19:58:49 +02:00
Felix e103843ffd Colour path white-on-black 2018-10-15 19:58:49 +02:00
Muhammad Talal Anwar a643cc3801 Add Mímir to Ports section in the readme (#438) 2018-10-15 22:14:11 +07:00
Mathias Fredriksson 9325fe60f8 Avoid calling zle reset-prompt in precmd (#431)
There's no need to call zle reset-prompt in precmd since the prompt has
yet to be rendered. This commit separates the widget functionality
(reset prompt) and restoring the prompt symbol.
2018-08-25 02:14:18 +07:00
Mathias Fredriksson 197012b0a9 Simplify async tasks by not passing $PWD (#430) 2018-08-21 15:40:41 +07:00
Mathias Fredriksson 6203b39715 Abort git check if pwd has changed after invocation (#428)
Fixes #363
2018-08-20 17:05:01 +07:00
Mathias Fredriksson 16b141b11a Update zsh-async to 1.7.0 (#429)
Fixes #420
2018-08-20 16:53:38 +07:00
Mathias Fredriksson 7aade5fca2 1.8.0 2018-08-20 11:28:23 +03:00
Mathias Fredriksson fbc7d825c1 Advice against enabling incompatible Oh-My-Zsh plugins 2018-08-20 10:29:25 +03:00
Mathias Fredriksson 872153f446
Show warning when Oh My Zsh themes are enabled (#426)
The logic here is that if we unset ZSH_THEME during Pure init, we guard
against this scenario:

prompt pure
source $ZSH/oh-my-zsh.zsh

Also, by unsetting ZSH_THEME we can detect the following scenario:

prompt pure
source $ZSH/oh-my-zsh.zsh

And in this case, we show a warning, because there's no telling what
that OMZ theme might have done (precmd hooks, etc).
2018-08-12 12:17:42 +03:00
Mathias Fredriksson 5976e54a7b
Add support for VI-mode indicator (#405)
* Add support for VI-mode indicator

Related: #308, #208, #184 and #98.

* Document VI-mode limitation (Zsh 5.3+)
2018-07-30 19:13:35 +03:00
Dennis Eriksen c8aa41614b Remove unused function for computing string length (#418)
This function has not been used since commit
4cdd0cf4f4, when we started performing
git-checks asynchronously.
2018-07-05 22:20:42 +03:00
Dennis Eriksen 9aba02176a Update fpath-reference link (#417) 2018-07-04 15:44:20 +03:00
Mathias Fredriksson 37fc76d8a7
Prevent IPv6 regexp from capturing the time (#413)
Fixes #403.
2018-06-18 21:51:36 +03:00
Mathias Fredriksson 2e4879390e
Prevent hostname from showing up in local X sessions (#398)
* Prevent hostname from showing up in local X sessions

This change prevents the hostname from showing up when a terminal is
opened inside a local X session (displayed as (:1)).

Fixes a regression introduced in #393.

* Implement a more robust remote connection detection (who)

First, we switch from `who am i` to `who -m` because this is the POSIX
way and macOS supports it as well.

Second, if the above fails, we fall back to using just `who` and grep
the line that represents our TTY. This works e.g. with busybox systems.

Finally, we use (extremely) simplified regular expressions for detecting
IPv4, IPv6 and hostname. This is a best-effort attempt at detecting the
remote connections when SSH_CONNECTION is not set.

* Inherit SSH connection detection inside tmux or other subshells

* Store match and use upper case export for consistency

This will also help with debugging if a user ever runs into a problem
where the user/host is shown when it should not be:

2018-05-13 21:58:43 +03:00
Mathias Fredriksson d472db9029 Make sure local HUP trap is unset during git fetch
This allows for signal propagation when the async worker is flushed.

Fixes #408.
2018-05-08 18:42:59 +03:00
Mathias Fredriksson 60f54c65d3
Improve the debug prompt (PS4) (#396)
* Improve the debug prompt (PS4)

Add colors, to highlight the current function and de-empasize line numbers.

Add an extra line number (`%I`) which represents the line number in the file
where the code resides (by default, only the function line number is shown,
making it hard(er) to find the relevant code).

Repeat the + character to indicate the current execution depth, e.g. when a 
function calls another, the depth is increased. This allows you to quickly see 
which function invoked which.

* Add filename to debug prompt

Add filename (without path) to the debug prompt, when applicable and makes sure
to avoid displaying duplicate information. Say, when a file is being parsed,
both %N and %x contain the same value (file path). In this case, we only show
one value.

There is a slight cost to doing the extra processing when testing in
iTerm (unscientific benchmark):

	zsh -x  0.30s user 0.14s system 57% cpu 0.754 total


	zsh -x  0.49s user 0.16s system 65% cpu 0.988 total

I think this is within an acceptable range.
2018-05-07 20:23:00 +03:00
Mathias Fredriksson 81bd8996f7 Show options as a table in readme (#407) 2018-05-08 00:09:01 +07:00
Mathias Fredriksson e9c15e8bbc Remove unfrequent FAQs from readme (#406) 2018-05-08 00:07:32 +07:00
Mathias Fredriksson a90b1bc04a
Prevent interactive prompts during git fetch (#397)
We set the shell into MONITOR mode to prevent password prompts from
hijacking the TTY. If the command is suspended we know it's trying
something not nice. So we kill it.

This seems a bit crazy, but at least it does not seem to affect
performance (relatively). I also have found no other way to work around
these issues.

Although we already set:

export GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-"ssh"} -o BatchMode=yes"

It is not sufficient. For example, when a SSH configuration entry
contains the ProxyJump option it will usually invoke a new instance of
ssh which does not obey the BatchMode option we specified.

I tried both zsh 4.3.17 and 5.0.2 to be sure it doesn't break easily...

Fixes #373.
2018-05-02 20:43:53 +03:00
Mathias Fredriksson 49ca46dce8
Set title via atomic print statement (#399)
Previously, `setopt xtrace` would produce terminal bell rings (by \a)
whenever the title was set because of debug output between print
statements. As a result, the title was not set and the terminal bell

This change also utilizes the improved ssh connection detection to
provide hostname in title when changing user on remote machines.
2018-05-02 20:38:54 +03:00
Mathias Fredriksson 5a39be4e8f Revert local prompt_opts, breaks promptinit 2018-05-01 20:12:42 +03:00
Mathias Fredriksson 20b66c96af Fix for setopt not taking effect when sourcing pure
Fixes #401, again.
2018-05-01 20:08:15 +03:00
Mathias Fredriksson 3e27c389eb Fix prompt_pure_state on older versions of zsh
On some versions of zsh, we cannot declare and assign an associative
array on the same line.
2018-05-01 19:30:31 +03:00
Mathias Fredriksson c74d5dd3dd Fix wrong placement of localoptions during prompt init
Fixes #401.
2018-05-01 15:13:43 +03:00
Mathias Fredriksson 9fa64040b1 Fix line erasure when terminal output does not end in newline (#391)
It seems that adding the initial newline in `$PROMPT` allows ZLE to
erase the entile line where the newline began. This is problematic when
command output does not end with its own newline. A subsequent terminal
resize or prompt update that triggers a prompt redraw will then erase
the line.

To fix this, we separate the newline from the prompt by calling print
manually during precmd.

Previously, Pure tried to keep any potential prefixes the user might
have added to the PROMPT (before preprompt). This fix no longer allows
such prefixes as doing so would be hackish, and likely a recipe for
other unforseen behavior.

NOTE: Because the newline is printed by the Pure precmd hook, it's
possible that another precmd hook is run afterwards, and if that hook
outputs any text, the newline will appear in the wrong place. A possible
solution would be to delay adding the hook or at a later point sort the
hooks so that Pure is last.

Fixes #390, #376.
2018-04-30 01:26:22 +07:00
Mathias Fredriksson 17e23aecda
Try to detech SSH connection when SSH_CONNECTION is unset (#393)
This change allows us to detect SSH connections even when the
`$SSH_CONNECTION` environment variable is gone. This can happen when a
user changes to another user (`su`, `sudo`) or the environment is
otherwise reset.

By checking the output of `who am i` for a parenthesis at the end, we
assume that said parenthesis must contain either an IPv4 or IPv6
address, indicating that this is a remote session.

The reliablity of this assumption has not been analyzed to a great
degree, there could be false positives, or systems that do not format
the output in this way.

Fixes #382.
2018-04-29 15:06:03 +03:00
Mathias Fredriksson 0d137f7e59 Always force BatchMode for the Git SSH command (#392)
The previous implementation did not disable SSH password prompts when
`GIT_SSH_COMMAND` has been set. This allowed the zsh-async worker to
"break" due to an interactive program capturing keystrokes, which were
actually output from the worker.

Fixes #373.
2018-04-28 19:59:59 +07:00
Mathias Fredriksson fa9137ecec 1.7.0 2018-04-22 13:32:31 +03:00
Mathias Fredriksson a2cfb4e7b8
Avoid setting title over serial console (#388) 2018-04-22 13:23:36 +03:00
Mathias Fredriksson afa625b3bc
Hide virtualenv when explicitly disabled by the user (#381)
When `VIRTUAL_ENV_DISABLE_PROMPT` is set (to true) by the user, Pure
will not display the virtualenv in the prompt. Setting this manually
likely means the user does not care.

The user can, at any point, run `export VIRTUAL_ENV_DISABLE_PROMPT=1`
and the virtualenv will disappear. Likewise,
`unset VIRTUAL_ENV_DISABLE_PROMPT` will bring it back.

Closes #350.

A big thanks to classner and pfrybar for their efforts and reference
implementations, inspiring this one.
2018-04-18 18:38:17 +03:00
Alexander Kapshuna 6c86c747df Add install guide for Zplugin (#386) 2018-04-18 18:23:03 +03:00
Dustin Specker 62992b2783 Update URL to Droid Sans Mono font (#387) 2018-04-17 10:20:18 +07:00
Mathias Fredriksson a3b22b242d Prevent multiple prompt resets in one execution cycle (#368)
* Update zsh-async to 1.6.0 for buffer status indicator

* Prevent multiple prompt resets in one execution cycle

The prompt ends up in a weird state when `zle reset-prompt` is called
multiple times during one execution cycle. This can happen when multiple
async tasks finish at nearly the same time. What happened here is that
`async_process_results` called `prompt_pure_async_callback` multiple
times during it's execution. In turn, `prompt_pure_async_callback` did
multiple calls to `zle reset-prompt`. My theory is that ZLE ends up in a
weird state that is reset after all the current code has completed

This behavior is observable when the prompt "moves upwards" and erases
previous lines in the terminal.

Fixes #356.
2017-11-22 13:36:09 +07:00
Mathias Fredriksson f23e72640f More thorough handling (hiding) of match results
In prompt_pure_preexec we perform a match using both the (#b) glob flag
(match, mbegin, mend) and the (#m) flag (MATCH, MBEGIN, MEND). We must
mark these variables local to avoid triggering the WARN_CREATE_GLOBAL

This commit also adds MBEGIN and MEND to places where only MATCH was
marked local.

2017-11-01 18:47:45 +02:00
Mathias Fredriksson f7893660f1 Avoid implicit creation of global var prompt_pure_git_arrows
This should have been part of #347.
2017-10-31 21:31:55 +02:00
Mathias Fredriksson a95d55cc7d 1.6.0 2017-10-27 19:52:31 +03:00
Richard Oyudo aed646a06c Link to pure.zsh and async.zsh for better clarity (#358) 2017-10-24 00:44:56 +07:00
Sindre Sorhus 9bda548c71 Readme tweaks 2017-10-19 23:53:58 +07:00
Sindre Sorhus 057354870f Link to a Pure-inspired prompt done in Rust 2017-10-19 23:49:41 +07:00
Mathias Fredriksson ccc4d11b58 Avoid implicit global var creation and cleanup (#347)
This change will prevent `setopt warn_create_global` from showing errors
and give the reader a better understanding of how the variable is used
(global or local scope).

The preprompt render guard logic of `prompt_pure_cmd_timestamp` was also
removed because this can no longer happen. If a command is running, ZLE
will not be active and `zle reset-prompt` will do nothing.

Closes #345.
2017-10-18 00:31:12 +03:00
Hugo Locurcio 4082418e4f Fix grammar in readme (#344) 2017-09-07 20:29:41 +07:00
Mathias Fredriksson 2181e9033e Update oh-my-zsh instructions in readme
Oh-my-zsh overrides PS1 even when no theme is set, this commit adds a
note to the readme about the need to activate Pure *after* oh-my-zsh.

Closes #315.
2017-08-12 19:23:14 +03:00