Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Add Async Functionality per Segment #1176

Draft
wants to merge 64 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2b4ea24
Add segment tags
dritter Feb 20, 2019
2cd1651
Split tags properly
dritter Feb 20, 2019
53feb12
Match joined tag non-greedy
dritter Feb 21, 2019
b9fa56a
Check tags (joined/custom) the new way
dritter Feb 21, 2019
4ba4274
Fix tests
dritter Feb 21, 2019
2d23f36
Read in segment information as array
dritter Feb 23, 2019
c8acf6a
Avoid warning "parameter not set", when using NO_UNSET by testing the…
dritter Feb 24, 2019
71813ca
Fix test
dritter Feb 24, 2019
bc4dd60
Extract p9k::segment_is_tagged_as function for easier handling of tags
dritter Feb 24, 2019
ce2c020
Split tags by whitespace
dritter Feb 24, 2019
4fed877
Search array more readable
dritter Feb 25, 2019
0591b6c
Remove remainings of Async Generator
dritter Feb 28, 2019
d510f69
Add async tag that sets up ZSH-Async
dritter Feb 28, 2019
6ae2076
Render segments asynchronously if they are tagged with ::async
dritter Feb 28, 2019
86b4869
Change PWD inside async worker if changed outside
dritter Feb 28, 2019
5f2cdb5
Iterate cache items in the order they were added to the cache
dritter Mar 1, 2019
05a0589
Remove unnecessary subshell
dritter Mar 1, 2019
5ae28b6
Fix replacing segment data with async segments
dritter Mar 1, 2019
f9bbfb0
Remove another reference to old Async Generator
dritter Mar 1, 2019
77695db
Better appending of variables
dritter Mar 2, 2019
a9cd3f6
Remove redundant variable declaration
dritter Mar 2, 2019
72cb52b
Reorder variables
dritter Mar 2, 2019
d1f941f
Fix rendering of segments
dritter Mar 2, 2019
3165c77
Add should_be_printed information to serialized segment
dritter Mar 2, 2019
04de77f
The metadata of each segment must be processed by P9K engine
dritter Mar 2, 2019
1db5ea0
Fix pyenv segment
dritter Mar 3, 2019
dc61cbf
Fix rbenv segment
dritter Mar 3, 2019
0b67dba
Fix symfony2_tests and rspec_stats segments
dritter Mar 3, 2019
7924fbb
Fix Typo
dritter Mar 3, 2019
7199c43
Avoid warning, if no async segment is in use and ZSH-Async was not lo…
dritter Mar 3, 2019
fd2bf4d
Fix vi_mode segment
dritter Mar 4, 2019
108c6cf
Fix docblocks
dritter Mar 4, 2019
6670225
Replace __p9k_config with __P9K_DATA
dritter Mar 4, 2019
c0b3a0d
Better caching of tagged segments
dritter Mar 4, 2019
d463534
Add documentation
dritter Mar 5, 2019
0bf917b
Avoid prompt being eaten up
dritter Mar 5, 2019
3dd77b7
Avoid async_eval tasks from triggering prompt rendering
dritter Mar 5, 2019
3e6b0ad
Fix recognising custom tagged segments
dritter Mar 6, 2019
fdeaeae
Avoid subshells for non async segments
dritter Mar 6, 2019
e28ef3a
Fix variable declaration
dritter Mar 6, 2019
eff9fb9
Store segment result in __P9K_DATA
dritter Mar 8, 2019
ee73ace
Fix status segment
dritter Mar 11, 2019
3f5445d
Evaluate parenthesis as segment condition as well
dritter Mar 11, 2019
bd2427a
Make nvm segment always print to cache
dritter Mar 12, 2019
0b3eaa5
Make battery segment always fill the cache
dritter Mar 12, 2019
e8fa430
Make custom segments always fill the cache
dritter Mar 12, 2019
99c898f
Register custom segments as early as possible
dritter Mar 12, 2019
dd6b97a
Merge remote-tracking branch 'ben/next' into conditional_async
dritter Mar 13, 2019
4d27450
Fix tests that use __p9k_build_left_prompt
dritter Mar 14, 2019
36f808f
Fix condition of status segment
dritter Mar 14, 2019
f4af33d
Fix tests that call prompt_* functions directly
dritter Mar 14, 2019
9402f4d
Merge branch 'next' into conditional_async
dritter Apr 1, 2019
7ce2738
Make gitstatus always fill the cache
dritter Apr 1, 2019
7918c7d
Add p9k::segment_in_use again
dritter Apr 1, 2019
0c76270
Improve performance of vi_mode segment
dritter Apr 1, 2019
7f10d00
Fix vi_mode segment
dritter Apr 1, 2019
b8de242
Force redisplay the prompt
dritter Jul 2, 2019
c6c1c38
Update the environment in the async worker before building the prompt
dritter Jul 4, 2019
bf2ccbc
Fix iteration on segment cache in __p9k_render
laggardkernel Jul 9, 2019
c0dc9da
Generalize snippet for refreshing a single item in the cache
laggardkernel Jul 9, 2019
a53d12d
Early exit as normal without helper segment_no_print
laggardkernel Jul 6, 2019
691e076
Assume a segment won't be displayed by default for a normal early exit
laggardkernel Jul 9, 2019
c8aacf6
Merge pull request #41 from laggardkernel/fix-iteration-in-render
dritter Jul 9, 2019
a507b7a
Merge pull request #42 from laggardkernel/async-with-section-untouched
dritter Jul 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions functions/autoload/__p9k_segment_should_be_joined
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ local last_segment_index=$2
local -a elements
elements=(${=3})

local current_segment=${elements[$current_index]}
local raw_current_segment=${elements[$current_index]}
local -a current_segment=(${(s.::.)raw_current_segment})
local joined=false
if [[ ${current_segment[-7,-1]} == '_joined' ]]; then
if p9k::segment_is_tagged_as "joined" "${current_segment}"; then
joined=true
# promote segment to a full one, if the predecessing full segment
# was conditional. So this can only be the case for segments that
Expand All @@ -47,11 +48,12 @@ if [[ ${current_segment[-7,-1]} == '_joined' ]]; then
# segment as well.
local examined_index=$((current_index - 1))
while (( ${examined_index} > ${last_segment_index} )); do
local previous_segment=${elements[$examined_index]}
local raw_previous_segment=${elements[$examined_index]}
local -a previous_segment=(${(s.::.)raw_previous_segment})
# If one of the examined segments is not joined, then we know
# that the current segment should not be joined, as the target
# segment is the wrong one.
if [[ ${previous_segment[-7,-1]} != '_joined' ]]; then
if ! p9k::segment_is_tagged_as "joined" "${previous_segment}"; then
joined=false
break
fi
Expand Down
19 changes: 19 additions & 0 deletions functions/utilities.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,25 @@ function p9k::set_default() {
p9k::defined "$varname" || typeset -g "$varname"="$default_value"
}

###############################################################
# @description
# Tests if a segment is tagged as given tag.
##
# @args
# $1 string The tag to test
# $2 array The segments tags
##
# @returns
# 0 if the segment contains the tag
##
function p9k::segment_is_tagged_as() {
local tag="${1}"
# All following parameters
local segment_meta=(${=@[2,-1]})

[[ "${segment_meta[(re)${tag}]:-}" == "${tag}" ]]
}

###############################################################
# @description
# Converts large memory values into a human-readable unit (e.g., bytes --> GB)
Expand Down
Loading