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

Commit 61b665f

Browse files
authored
Merge pull request #1187 from dritter/merge_067
Merge master into next
2 parents 6749909 + d4b3867 commit 61b665f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+802
-480
lines changed

.github/ISSUE_TEMPLATE.md renamed to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
110
Thanks for opening an issue! For a project that deals with as many different things as P9k, debugging problems can be difficult. Please follow the guide, below, to create a bug report that will help us help you!
211

312
### Before Opening a Bug
@@ -14,11 +23,11 @@ Most issues are best explained with a screenshot. Please share one if you can!
1423

1524
#### Have you tried to debug or fix it?
1625

17-
1826
Have you tinkered with your settings, and what happened when you did? Did you find a bit of code that you think might be the culprit? Let us know what you've done so far!
1927

2028
#### Environment Information
21-
This information will help us understand your configuration.
29+
30+
This information will help us understand your configuration.
2231

2332
- What version of ZSH are you using? You can use `zsh --version` to see this.
2433
- Do you use a ZSH framework (e.g., Oh-My-ZSH, Antigen)?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Performance Issue
3+
about: For performance Issues
4+
title: "[Performance]"
5+
labels: performance
6+
assignees: ''
7+
8+
---
9+
10+
Sorry to hear that the performance of P9K is not adequate. To fix this, please provide us with some hints.
11+
12+
### Your Hardware
13+
14+
Disk I/O is critical for P9K, so do you use a spinning disk, or a SSD?
15+
16+
### Virtualization
17+
18+
Do you use P9K in some sort of virtualization? This is also the case, if you use WSL on Windows..
19+
20+
### How Fast is Fast
21+
22+
Could you quantify how fast the specific segment is, that you think is slow?
23+
For example, if you think the `vcs` segment is slow, could you execute this command in the directory, where the segment is slow:
24+
25+
```zsh
26+
time (repeat 10; do; prompt_vcs left 1 false >/dev/null; done;)
27+
```
28+
29+
Also, please provide us with some context around the segment. In the `vcs` example:
30+
31+
- How big is the repo?
32+
- Does it contain a lot of untracked files?
33+
- Does it contain a lot of git submodules?
34+
- Does it contain a lot of files in general?
35+
36+
Additionally, you could install [zsh-prompt-benchmark](https://github.com/romkatv/zsh-prompt-benchmark), to benchmark the general performance of ZSH and P9K.
37+
38+
If you don't know which segment is slow, could you remove one by one, and spot the one that made the greatest impact?

.github/PULL_REQUEST_TEMPLATE.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@ Once you have submitted your PR, P9k core contributors will review the code and
1414
Please follow this template for creating your PR:
1515

1616
#### Title
17+
1718
Please make the title of your PR descriptive! If appropriate, please prefix the title with one of these tags:
1819

19-
- [Bugfix]
20-
- [New Segment]
21-
- [Docs]
22-
- [Enhancement]
23-
20+
- [Bugfix]
21+
- [New Segment]
22+
- [Docs]
23+
- [Enhancement]
24+
2425
#### Description
26+
2527
Please describe the contribution your PR makes! Screenshots are especially helpful, here, if it's a new segment.
2628

2729
If your PR is addressing an issue, please reference the Issue number here.
2830

2931
#### Questions
30-
Is there something in your PR you're not sure about or need help with? Is there a particular piece of code you would like feedback on? Let us know here!
31-
3232

33+
Is there something in your PR you're not sure about or need help with? Is there a particular piece of code you would like feedback on? Let us know here!

CHANGELOG.md

+26
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@
5454
- Replaced all tabs with spaces
5555
- Removed `rbenv` from default segments
5656

57+
## v0.6.7
58+
59+
- PR #1175 - Fix home dir shortening when using package_name truncation strategy
60+
- PR #1158 - [Bugfix] dir: Fix package name path truncation inside home dir
61+
- PR #1157 - Hide stderr from git ls-files
62+
- PR #1154 - Fix issues with debug/fonts script in Konsole
63+
- PR #1151 - [Bugfix] Only abbreviate $HOME at the beginning of cwd
64+
- PR #1148 - Remove checking for NODEENV_DISABLE_PROMPT
65+
- PR #1147 - Fix newlines in ZSH 5.7
66+
- PR #1149 - Fix RVM
67+
- PR #1128 - [Bugfix] virtualenv prompt displaying
68+
- PR #981 - [Bugfix] Fix for #974
69+
- PR #1126 - Use ip command for VPN segment
70+
- PR #1079 - [Bugfix] Update VIRTUAL_ENV_DISABLE_PROMPT value
71+
- PR #1080 - [Bugfix] Port #1071 to `master` (Fix fatal errors emitted by untracked file check in vcs.zsh)
72+
- PR #1074 - Add vcs vulnerability tests master
73+
- PR #1070 - [Docs] Uniformly apply inline code formatting in README
74+
- PR #1065 - Protect locale
75+
- PR #1048 - Speedup Improvements in `vcs` segment
76+
- PR #1037 - Fix vpn_ip segment
77+
- PR #1036 - Make truncate with package name work without setting shorten length
78+
- PR #1020 - Fix context spec
79+
- PR #990 - [Docs] Add forgotten backtick
80+
- PR #981 - Avoid error if `/etc/os-release` does not exist
81+
- PR #966 - [Bugfix] Fix icons cut off in RPROMPT segments
82+
5783
## v0.6.6
5884

5985
- The `rbenv` segment is no longer a default segment in the LPROMPT.

debug/font-issues.zsh

+16-25
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ END
192192
;;
193193

194194
"deepin-terminal"*)
195-
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a " " b}' \
195+
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a,b}' \
196196
"${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")"
197197
;;
198198

199199
"GNUstep_Terminal")
200200
term_font="$(awk -F '>|<' '/>TerminalFont</ {getline; f=$3}
201-
/>TerminalFontSize</ {getline; s=$3} END {print f " " s}' \
201+
/>TerminalFontSize</ {getline; s=$3} END {print f,s}' \
202202
"${HOME}/GNUstep/Defaults/Terminal.plist")"
203203
;;
204204

@@ -208,34 +208,26 @@ END
208208
;;
209209

210210
"kitty"*)
211-
setopt nullglob
212-
confs=({$KITTY_CONFIG_DIRECTORY,$XDG_CONFIG_HOME,~/Library/Preferences,~/.config}/kitty/kitty.con?)
213-
unsetopt nullglob
214-
215-
[[ -f "${confs[1]}" ]] || return
211+
kitty_config="$(kitty --debug-config)"
212+
[[ "$kitty_config" != *font_family* ]] && return
216213

217-
term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ {
218-
$1 = "";
219-
gsub(/^[[:space:]]/, "");
220-
font = $0
221-
}
222-
/^([[:space:]]*|[^#_])font_size[[:space:]]+/ {
223-
size = $2
224-
}
225-
END { print font " " size}' "${confs[1]}")"
214+
term_font_size="${kitty_config/*font_size}"
215+
term_font_size="${term_font_size/$'\n'*}"
216+
term_font="${kitty_config/*font_family}"
217+
term_font="${term_font/$'\n'*} $term_font_size"
226218
;;
227219

228220
"konsole" | "yakuake")
229221
# Get Process ID of current konsole window / tab
230222
child="$(get_ppid "$$")"
231223

232-
IFS=$'\n' read -d "" -ra konsole_instances < <(qdbus | grep -F 'org.kde.konsole')
224+
declare -a konsole_instances; konsole_instances=( "${(@f)"$(qdbus | grep -F 'org.kde.konsole')"/ /}" )
233225

234226
for i in "${konsole_instances[@]}"; do
235-
IFS=$'\n' read -d "" -ra konsole_sessions < <(qdbus "$i" | grep -F '/Sessions/')
227+
declare -a konsole_sessions; konsole_sessions=( "${(@f)"$(qdbus "$i" | grep -F '/Sessions/')"}" )
236228

237229
for session in "${konsole_sessions[@]}"; do
238-
if ((child == "$(qdbus "$i" "$session" processId)")); then
230+
if ((child == $(qdbus "$i" "$session" processId))); then
239231
profile="$(qdbus "$i" "$session" environment |\
240232
awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')"
241233
break
@@ -249,7 +241,7 @@ END
249241
profile_filename="${profile_filename/$'\n'*}"
250242

251243
[[ "$profile_filename" ]] && \
252-
term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")"
244+
term_font="$(awk -F '=|,' '/Font=/ {print $2,$3}' "$profile_filename")"
253245
;;
254246

255247
"lxterminal"*)
@@ -263,7 +255,7 @@ END
263255
mateterm_config="/tmp/mateterm.cfg"
264256

265257
# Ensure /tmp exists and we do not overwrite anything.
266-
if [[ -d /tmp && ! -f "$mateterm_config" ]]; then
258+
if [[ -d "/tmp" && ! -f "$mateterm_config" ]]; then
267259
mate-terminal --save-config="$mateterm_config"
268260

269261
role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)"
@@ -308,7 +300,7 @@ END
308300
;;
309301

310302
"qterminal")
311-
term_font="$(awk -F '=' '/fontFamily=/ {a=$2} /fontSize=/ {b=$2} END {print a " " b}' \
303+
term_font="$(awk -F '=' '/fontFamily=/ {a=$2} /fontSize=/ {b=$2} END {print a,b}' \
312304
"${XDG_CONFIG_HOME}/qterminal.org/qterminal.ini")"
313305
;;
314306

@@ -328,7 +320,7 @@ END
328320
# On Linux we can get the exact path to the running binary through the procfs
329321
# (in case `st` is launched from outside of $PATH) on other systems we just
330322
# have to guess and assume `st` is invoked from somewhere in the users $PATH
331-
[[ -L /proc/$parent/exe ]] && binary="/proc/$parent/exe" || binary="$(type -p st)"
323+
[[ -L "/proc/$parent/exe" ]] && binary="/proc/$parent/exe" || binary="$(type -p st)"
332324

333325
# Grep the output of strings on the `st` binary for anything that looks vaguely
334326
# like a font definition. NOTE: There is a slight limitation in this approach.
@@ -381,8 +373,7 @@ END
381373
term_font="$(trim "${term_font/*"faceName:"}")"
382374

383375
# xft: isn't required at the beginning so we prepend it if it's missing
384-
[[ "${term_font:0:1}" != "-" && \
385-
"${term_font:0:4}" != "xft:" ]] && \
376+
[[ "${term_font:0:1}" != "-" && "${term_font:0:4}" != "xft:" ]] && \
386377
term_font="xft:$term_font"
387378

388379
# Xresources has two different font formats, this checks which

functions/utilities.zsh

+55
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,58 @@ function p9k::find_first_non_empty() {
394394
shift
395395
done
396396
}
397+
398+
# Parse IP address from ifconfig on OSX and from IP on Linux
399+
# Parameters:
400+
# $1 - string The desired Interface
401+
# $2 - string A root prefix for testing purposes
402+
function p9k::parseIp() {
403+
local desiredInterface="${1}"
404+
405+
if [[ -z "${desiredInterface}" ]]; then
406+
desiredInterface="^[^ ]+"
407+
fi
408+
409+
local ROOT_PREFIX="${2}"
410+
if [[ "$OS" == "OSX" ]]; then
411+
# Get a plain list of all interfaces
412+
local rawInterfaces="$(${ROOT_PREFIX}/sbin/ifconfig -l 2>/dev/null)"
413+
# Parse into array (split by whitespace)
414+
local -a interfaces
415+
interfaces=(${=rawInterfaces})
416+
# Parse only relevant interface names
417+
local pattern="${desiredInterface}[^ ]?"
418+
local -a relevantInterfaces
419+
for rawInterface in $interfaces; do
420+
[[ "$rawInterface" =~ $pattern ]] && relevantInterfaces+=( $MATCH )
421+
done
422+
local newline=$'\n'
423+
for interfaceName in $relevantInterfaces; do
424+
local interface="$(${ROOT_PREFIX}/sbin/ifconfig $interfaceName 2>/dev/null)"
425+
if [[ "${interface}" =~ "lo[0-9]*" ]]; then
426+
continue
427+
fi
428+
# Check if interface is UP.
429+
if [[ "${interface//${newline}/}" =~ "<([^>]*)>(.*)inet[ ]+([^ ]*)" ]]; then
430+
local ipFound="${match[3]}"
431+
local -a interfaceStates=(${(s:,:)match[1]})
432+
if [[ "${interfaceStates[(r)UP]}" == "UP" ]]; then
433+
echo "${ipFound}"
434+
return 0
435+
fi
436+
fi
437+
done
438+
else
439+
local -a interfaces
440+
interfaces=( "${(f)$(${ROOT_PREFIX}/sbin/ip -brief -4 a show 2>/dev/null)}" )
441+
local pattern="^${desiredInterface}[ ]+UP[ ]+([^/ ]+)"
442+
for interface in "${(@)interfaces}"; do
443+
if [[ "$interface" =~ $pattern ]]; then
444+
echo "${match[1]}"
445+
return 0
446+
fi
447+
done
448+
fi
449+
450+
return 1
451+
}

generator/default.p9k

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function __p9k_left_prompt_segment() {
9292

9393
# Print the visual identifier and content if any
9494
local visual_identifier
95-
[[ -n "${SEGMENT_ICON}" ]] && visual_identifier="$__P9K_DATA[${STATEFUL_NAME}_VI]${SEGMENT_ICON}%f"
95+
[[ -n "${SEGMENT_ICON}" ]] && visual_identifier="$__P9K_DATA[${STATEFUL_NAME}_VI]${SEGMENT_ICON}"
9696
[[ -n "${content}" ]] && content="${fg}${content}"
9797
[[ -n "${visual_identifier}" && -n "${content}" ]] && visual_identifier="${visual_identifier}${middle_ws}"
9898
echo -n "${visual_identifier}${content}${right_ws}"

segments/anaconda/anaconda.spec

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
3838
CONDA_ENV_PATH=/tmp
3939
unset CONDA_PREFIX
4040

41-
assertEquals "%K{004} %F{000}icon-here%f %F{000}(tmp) %k%F{004}%f " "$(__p9k_build_left_prompt)"
41+
assertEquals "%K{004} %F{000}icon-here %F{000}(tmp) %k%F{004}%f " "$(__p9k_build_left_prompt)"
4242
}
4343

4444
function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
@@ -52,7 +52,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
5252
unset CONDA_ENV_PATH
5353
local CONDA_PREFIX="test"
5454

55-
assertEquals "%K{004} %F{000}icon-here%f %F{000}(test) %k%F{004}%f " "$(__p9k_build_left_prompt)"
55+
assertEquals "%K{004} %F{000}icon-here %F{000}(test) %k%F{004}%f " "$(__p9k_build_left_prompt)"
5656
}
5757

5858
function testAnacondaSegmentWorks() {
@@ -66,7 +66,7 @@ function testAnacondaSegmentWorks() {
6666
local CONDA_ENV_PATH=/tmp
6767
local CONDA_PREFIX="test"
6868

69-
assertEquals "%K{004} %F{000}icon-here%f %F{000}(tmptest) %k%F{004}%f " "$(__p9k_build_left_prompt)"
69+
assertEquals "%K{004} %F{000}icon-here %F{000}(tmptest) %k%F{004}%f " "$(__p9k_build_left_prompt)"
7070
}
7171

7272
source shunit2/shunit2

segments/aws_eb_env/aws_eb_env.spec

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
3434
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
3535
cd /tmp/powerlevel9k-test
3636

37-
assertEquals "%K{000} %F{002}🌱 %f %F{002}test %k%F{000}%f " "$(__p9k_build_left_prompt)"
37+
assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(__p9k_build_left_prompt)"
3838

3939
rm -fr /tmp/powerlevel9k-test
4040
cd -
@@ -55,7 +55,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirec
5555
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
5656
cd /tmp/powerlevel9k-test/1/12/123/1234/12345
5757

58-
assertEquals "%K{000} %F{002}🌱 %f %F{002}test %k%F{000}%f " "$(__p9k_build_left_prompt)"
58+
assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(__p9k_build_left_prompt)"
5959

6060
rm -fr /tmp/powerlevel9k-test
6161
cd -

segments/background_jobs/background_jobs.spec

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function testBackgroundJobsSegmentVerboseAlwaysPrintsZeroWithoutBackgroundJobs()
3535
# Load Powerlevel9k
3636
source segments/background_jobs/background_jobs.p9k
3737

38-
assertEquals "%K{003} %F{000}⚙%f %F{000}0 %k%F{003}%f " "$(__p9k_build_left_prompt)"
38+
assertEquals "%K{003} %F{000}⚙ %F{000}0 %k%F{003}%f " "$(__p9k_build_left_prompt)"
3939
}
4040

4141
function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
@@ -47,7 +47,7 @@ function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
4747

4848
# Load Powerlevel9k
4949
source segments/background_jobs/background_jobs.p9k
50-
assertEquals "%K{003} %F{000}⚙%f %k%F{003}%f " "$(__p9k_build_left_prompt)"
50+
assertEquals "%K{003} %F{000}⚙ %k%F{003}%f " "$(__p9k_build_left_prompt)"
5151
}
5252

5353
function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
@@ -60,7 +60,7 @@ function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
6060
# Load Powerlevel9k
6161
source segments/background_jobs/background_jobs.p9k
6262

63-
assertEquals "%K{003} %F{000}⚙%f %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
63+
assertEquals "%K{003} %F{000}⚙ %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
6464
}
6565

6666
function testBackgroundJobsSegmentWithVerboseMode() {
@@ -73,7 +73,7 @@ function testBackgroundJobsSegmentWithVerboseMode() {
7373
# Load Powerlevel9k
7474
source segments/background_jobs/background_jobs.p9k
7575

76-
assertEquals "%K{003} %F{000}⚙%f %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
76+
assertEquals "%K{003} %F{000}⚙ %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
7777
}
7878

7979
function testBackgroundJobsSegmentWorksWithExpandedMode() {
@@ -87,7 +87,7 @@ function testBackgroundJobsSegmentWorksWithExpandedMode() {
8787
# Load Powerlevel9k
8888
source segments/background_jobs/background_jobs.p9k
8989

90-
assertEquals "%K{003} %F{000}⚙%f %F{000}1r 2s %k%F{003}%f " "$(__p9k_build_left_prompt)"
90+
assertEquals "%K{003} %F{000}⚙ %F{000}1r 2s %k%F{003}%f " "$(__p9k_build_left_prompt)"
9191
}
9292

9393
source shunit2/shunit2

segments/battery/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ systems without a battery). It is supported on both OSX and Linux.
2828
|`P9K_BATTERY_LOW_THRESHOLD`|`10`|Threshold to consider battery level critical.|
2929
|`P9K_BATTERY_LOW_COLOR`|`"red"`|Color to indicate critically low charge level.|
3030
|`P9K_BATTERY_VERBOSE`|`true`|Display time remaining next to battery level.|
31+
|`P9K_BATTERY_HIDE_ABOVE_THRESHOLD`|`unset`|Threshold from which the battery segment should not be displayed.|
3132

3233
Note that you can modify the `_FOREGROUND` color without affecting the icon color.
3334

0 commit comments

Comments
 (0)