Commit Graph

80 Commits

Author SHA1 Message Date
Mathias Fredriksson
3dd645970e Evaluate $PROMPT at render time (#274)
This allows $PURE_PROMPT_SYMBOL to be modified at any point.
2017-01-18 23:29:19 +07:00
Mathias Fredriksson
ee0c6a445a Disable interactive passwords in SSH for git fetch (#269)
This commit fixes a problem where SSH (used by Git) is able to
interactively prompt for a password that can not be redirected to
`/dev/null`.

An interactive SSH password prompt inside the async worker does three
things:
1. Leave the `git fetch` hanging due to waiting for input
2. Capture part of the input to the async worker, thus creating
   nonsense commands
3. Use some characters from future async jobs as a password and
   attempts to login

Even if this was fixed in `zsh-async`, it is still good to disable the
password prompt to avoid issue numero uno.
2017-01-16 10:10:36 +07:00
Mathias Fredriksson
5ccc336b35 Restore prompt_subst setopt when rendering prompt (#231)
We store the user setting for `prompt_subst` before changing it in the
local scope of `prompt_pure_preprompt_render`. This allows us to restore
it when we render the real prompt (`PS1`) through `zle .redraw-prompt`.

Fixes #230.
2016-09-20 16:56:12 +03:00
Mathias Fredriksson
780d1a5a08 Prevent parameter expansion in preprompt
By unsetting `prompt_subst` for the `prompt_pure_preprompt_render`
function we can avoid e.g. git branch names with a `$`-sign to be
expanded as parameters.

Fixes #224 and #225 (as a result of 6cbd49a).
2016-08-25 19:00:23 +03:00
Mathias Fredriksson
753ef290f8 Revert "Fix double variable interpolation in branch name"
This reverts commit 6cbd49ad5c because it
broke users prompts if they didn't have `prompt_subst` set.
2016-08-25 18:49:07 +03:00
Mathias Fredriksson
6cbd49ad5c Fix double variable interpolation in branch name
This commit prevents a git branch named e.g. `$TMPPREFIX` from being
expanded into the actual contents of the `$TMPPREFIX` variable.

Fixes #224.
2016-08-25 12:22:38 +03:00
Mathias Fredriksson
e3f1f87fc3 Compare expanded preprompt when rendering (#214)
* Compare expanded preprompt when rendering

The expanded content of the preprompt was not considered previously when
checking if the content had changed. E.g. path changes were never detected.
The typeset (definition) and assignment are performed on separate lines as it
would cause issues otherwise.

Fixes #213.
2016-07-27 12:04:49 +03:00
Mathias Fredriksson
a0a3e88480 Use zle reset-prompt to restore cursor instead of relying on ansi codes
This fixes #191 and can be considered a more robust method of restoring cursor
position.
2016-02-15 19:01:22 +02:00
Mathias Fredriksson
79b1514fd4 Disable setting title in emacs terminal (not supported)
This fixes #188 and takes place of #190, at least for now.
2016-02-15 19:01:17 +02:00
Jonathan Dahan
2fcf5251b4 Use builtin cd, in case cd::cd has been redefined 2015-12-02 18:01:33 -05:00
Mathias Fredriksson
9de635ee10 Close #171 PR: Attempt to detect user initiated git fetch. Fixes #162 2015-11-18 02:20:23 +07:00
Mathias Fredriksson
a52e8a9469 Deduplicate code by creating a set_title function 2015-09-22 13:25:25 +03:00
Mathias Fredriksson
f3969755ae Render new preprompt with previous one in mind
This fixes #145 by calculating how many lines the previous preprompt
assumes in the current terminal window and either erases preprompt lines
that are no longer relevant or allocates more space for the new
preprompt.
2015-07-29 16:04:22 +03:00
Mathias Fredriksson
924b6291ab Refactor to avoid subshell usage, prefer variables
Performance tests indicate using a lot of subshells can lead to bad
performance.
2015-07-27 23:27:45 +03:00
Mathias Fredriksson
ba1f064357 Close #147 PR: Preserve preprompt on Ctrl+L. Fixes #145 2015-07-18 17:27:18 +02:00
Mathias Fredriksson
2509a1fac0 Remove cr from prompt_opts, fixes #127 2015-07-16 10:15:56 +03:00
Zhiming Wang
4a35b8002b fix last-char-of-preprompt-on-last-column condition
See https://github.com/sindresorhus/pure/pull/142#issuecomment-120961475.
2015-07-14 17:52:33 -07:00
Zhiming Wang
57bfd997a5 move subtraction by one out of prompt_pure_string_length
prompt_pure_string_length is used for calculating the length of the
preprompt, but the preprompt doesn't contain a newline, so we shouldn't
subtract by one in prompt_pure_string_length.

What should happen instead is that when we subtract one from the length
when we calculate the number of lines the preprompt occupies.
2015-07-14 17:50:31 -07:00
Mathias Fredriksson
b1b44b3204 Merge pull request #144 from zmwangx/rename-prompt-to-preprompt
prompt_pure_preprompt_render: rename prompt to preprompt
2015-07-15 03:23:58 +03:00
Mathias Fredriksson
a94ff2ff6b Default to 0 for git rev-list left and right. Fixes #137. 2015-07-14 23:09:32 +03:00
Alexander Pyatkin
579af2425b Close #140 PR: Add git arrows customization. Fixes #139. 2015-07-13 12:36:37 +02:00
Zhiming Wang
5f5c4d4856 prompt_pure_preprompt_render: rename prompt to preprompt
Preprompt and prompt are two distinct concepts in pure: the preprompt is
where the directory and git info live, whereas the prompt (`PROMPT`) is
as pure and simple as `%(?.%F{magenta}.%F{red})❯%f`.

In the `prompt_pure_preprompt_render` function though, prompt and
preprompt are used interchangeably, which makes it confusing the first
time one reads it. (The lines `[[ "${prompt_pure_last_preprompt}" !=
"${prompt}" ]]` and `prompt_pure_last_preprompt=$prompt` perfectly
illustrate the interchangeable use and the potential point of
confusion.)

Therefore, this commits corrects the problem by renaming the `prompt`
local variable to `preprompt`, and updating comments accordingly.
2015-07-13 02:11:16 -07:00
Mathias Fredriksson
5f5b990e2b Disable prompt expansion for running command 2015-06-16 14:54:43 +03:00
Mathias Fredriksson
a099059f15 Merge pull request #130 from zmwangx/rename-variables-for-readability
Rename two internal variables for readability
2015-06-14 11:26:40 +03:00
Zhiming Wang
fe6f11960c rename two internal variables for readability
* `prompt_pure_git_delay_dirty_check` holds the (finish) timestamp of
  the last dirty check (if the dirty check took more than 2 seconds);
  renamed to `prompt_pure_git_last_dirty_check_timestamp`.

* Local variable `dirty_check` holds the elapsed time in seconds since
  the last dirty check (if the timestamp is set); renamed to
  `time_since_last_dirty_check`.
2015-06-13 03:45:23 -07:00
Mathias Fredriksson
58167f1879 Use standard [[ ]] for conditional and add clarifications 2015-06-13 13:21:44 +03:00
Mathias Fredriksson
b55776e7aa fix: do the PURE_GIT_PULL check in the correct place 2015-06-02 20:16:27 +03:00
Mathias Fredriksson
fbca62ea3f Close #124 PR: Show hostname in terminal title if session is over ssh. 2015-06-01 13:27:44 +02:00
Mathias Fredriksson
016b5ec7db Use slightly faster git dirty check for untracked files 2015-06-01 13:09:15 +03:00
Mathias Fredriksson
d766c8b8d9 use cd -q to prevent hooks from firing 2015-05-27 19:30:12 +03:00
Mathias Fredriksson
e46c59ff45 prevent git status leakage when testing if dirty 2015-05-27 18:55:39 +03:00
Mathias Fredriksson
a57987499b fix paths that are split due to spaces in directory names 2015-05-27 18:44:40 +03:00
Sindre Sorhus
be77b9cb52 minor tweaks 2015-05-23 14:47:50 +02:00
Mathias Fredriksson
94ccd581dd Close #108 PR: Refactor async logic and allow for async git status.. 2015-05-23 13:32:21 +02:00
Mathias Fredriksson
786b580dc9 Only disable git terminal prompt for git fetch 2015-05-13 21:11:38 +03:00
Sindre Sorhus
5ade8aeb8a fast git execution 2015-04-27 09:31:21 +07:00
Erlend Hamberg
759736af29 Make sure git background fetch doesn't trigger gc 2015-03-10 19:27:39 +01:00
Mathias Fredriksson
f49c5bdf21 Fix ssh/root spacing issue. 2015-02-24 23:48:12 +02:00
Mathias Fredriksson
c1aa51346e Fix prompt precmd spacing.
Only add spaces if there is content.
2015-02-21 13:47:56 +02:00
Sindre Sorhus
f43ab97e1c disable auth prompting on git 2.3+ - fixes #76
https://github.com/blog/1957-git-2-3-has-been-released
2015-02-06 18:39:14 +07:00
Sindre Sorhus
6178236316 fix indent 2015-01-26 21:27:11 +08:00
Sindre Sorhus
0e279a17d4 fix indent 2014-12-31 13:42:31 +07:00
Sindre Sorhus
5bf86a48d5 Merge pull request #96 from danielhan/master
work tree check bug fix
2014-12-31 13:41:39 +07:00
Kanstantsin Kamkou
f38e463b3c Close #100 PR: PURE_PROMPT_SYMBOL added. 2014-12-31 13:39:05 +07:00
Michael Robinson
09740f68ea Close #94 PR: Show when root. 2014-12-15 12:50:28 +07:00
Daniel Han
dba5fc3400 work tree check bug fix 2014-11-29 00:25:51 -05:00
Zhong Jianxin
d4400b7bd9 Skip checking git remote if working tree is $HOME 2014-09-30 20:36:16 +08:00
Max Shishkin
1d97762b7a Close GH-80: Include untracked files in dirtiness check. Fixes #1, Fixes #79 2014-08-09 17:41:30 +02:00
Andrea Giardini
6675c0f3ae Double quote fix
Fixes #71
2014-06-08 19:54:55 +02:00
Jonathan Dahan
1ec0c5c742 Close GH-67: provide arrows for push and pull. 2014-05-29 17:16:00 +02:00