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

Commit

Permalink
Merge remote-tracking branch 'ben/master' into merge_067
Browse files Browse the repository at this point in the history
  • Loading branch information
dritter committed Mar 12, 2019
2 parents 6749909 + c4a8118 commit d4b3867
Show file tree
Hide file tree
Showing 57 changed files with 802 additions and 480 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

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!

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

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


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!

#### Environment Information
This information will help us understand your configuration.

This information will help us understand your configuration.

- What version of ZSH are you using? You can use `zsh --version` to see this.
- Do you use a ZSH framework (e.g., Oh-My-ZSH, Antigen)?
Expand Down
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/PERFORMANCE_ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Performance Issue
about: For performance Issues
title: "[Performance]"
labels: performance
assignees: ''

---

Sorry to hear that the performance of P9K is not adequate. To fix this, please provide us with some hints.

### Your Hardware

Disk I/O is critical for P9K, so do you use a spinning disk, or a SSD?

### Virtualization

Do you use P9K in some sort of virtualization? This is also the case, if you use WSL on Windows..

### How Fast is Fast

Could you quantify how fast the specific segment is, that you think is slow?
For example, if you think the `vcs` segment is slow, could you execute this command in the directory, where the segment is slow:

```zsh
time (repeat 10; do; prompt_vcs left 1 false >/dev/null; done;)
```

Also, please provide us with some context around the segment. In the `vcs` example:

- How big is the repo?
- Does it contain a lot of untracked files?
- Does it contain a lot of git submodules?
- Does it contain a lot of files in general?

Additionally, you could install [zsh-prompt-benchmark](https://github.com/romkatv/zsh-prompt-benchmark), to benchmark the general performance of ZSH and P9K.

If you don't know which segment is slow, could you remove one by one, and spot the one that made the greatest impact?
15 changes: 8 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ Once you have submitted your PR, P9k core contributors will review the code and
Please follow this template for creating your PR:

#### Title

Please make the title of your PR descriptive! If appropriate, please prefix the title with one of these tags:

- [Bugfix]
- [New Segment]
- [Docs]
- [Enhancement]
- [Bugfix]
- [New Segment]
- [Docs]
- [Enhancement]

#### Description

Please describe the contribution your PR makes! Screenshots are especially helpful, here, if it's a new segment.

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

#### Questions
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!


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!
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@
- Replaced all tabs with spaces
- Removed `rbenv` from default segments

## v0.6.7

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

## v0.6.6

- The `rbenv` segment is no longer a default segment in the LPROMPT.
Expand Down
41 changes: 16 additions & 25 deletions debug/font-issues.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ END
;;

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

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

Expand All @@ -208,34 +208,26 @@ END
;;

"kitty"*)
setopt nullglob
confs=({$KITTY_CONFIG_DIRECTORY,$XDG_CONFIG_HOME,~/Library/Preferences,~/.config}/kitty/kitty.con?)
unsetopt nullglob

[[ -f "${confs[1]}" ]] || return
kitty_config="$(kitty --debug-config)"
[[ "$kitty_config" != *font_family* ]] && return

term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ {
$1 = "";
gsub(/^[[:space:]]/, "");
font = $0
}
/^([[:space:]]*|[^#_])font_size[[:space:]]+/ {
size = $2
}
END { print font " " size}' "${confs[1]}")"
term_font_size="${kitty_config/*font_size}"
term_font_size="${term_font_size/$'\n'*}"
term_font="${kitty_config/*font_family}"
term_font="${term_font/$'\n'*} $term_font_size"
;;

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

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

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

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

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

"lxterminal"*)
Expand All @@ -263,7 +255,7 @@ END
mateterm_config="/tmp/mateterm.cfg"

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

role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)"
Expand Down Expand Up @@ -308,7 +300,7 @@ END
;;

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

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

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

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

# Xresources has two different font formats, this checks which
Expand Down
55 changes: 55 additions & 0 deletions functions/utilities.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,58 @@ function p9k::find_first_non_empty() {
shift
done
}

# Parse IP address from ifconfig on OSX and from IP on Linux
# Parameters:
# $1 - string The desired Interface
# $2 - string A root prefix for testing purposes
function p9k::parseIp() {
local desiredInterface="${1}"

if [[ -z "${desiredInterface}" ]]; then
desiredInterface="^[^ ]+"
fi

local ROOT_PREFIX="${2}"
if [[ "$OS" == "OSX" ]]; then
# Get a plain list of all interfaces
local rawInterfaces="$(${ROOT_PREFIX}/sbin/ifconfig -l 2>/dev/null)"
# Parse into array (split by whitespace)
local -a interfaces
interfaces=(${=rawInterfaces})
# Parse only relevant interface names
local pattern="${desiredInterface}[^ ]?"
local -a relevantInterfaces
for rawInterface in $interfaces; do
[[ "$rawInterface" =~ $pattern ]] && relevantInterfaces+=( $MATCH )
done
local newline=$'\n'
for interfaceName in $relevantInterfaces; do
local interface="$(${ROOT_PREFIX}/sbin/ifconfig $interfaceName 2>/dev/null)"
if [[ "${interface}" =~ "lo[0-9]*" ]]; then
continue
fi
# Check if interface is UP.
if [[ "${interface//${newline}/}" =~ "<([^>]*)>(.*)inet[ ]+([^ ]*)" ]]; then
local ipFound="${match[3]}"
local -a interfaceStates=(${(s:,:)match[1]})
if [[ "${interfaceStates[(r)UP]}" == "UP" ]]; then
echo "${ipFound}"
return 0
fi
fi
done
else
local -a interfaces
interfaces=( "${(f)$(${ROOT_PREFIX}/sbin/ip -brief -4 a show 2>/dev/null)}" )
local pattern="^${desiredInterface}[ ]+UP[ ]+([^/ ]+)"
for interface in "${(@)interfaces}"; do
if [[ "$interface" =~ $pattern ]]; then
echo "${match[1]}"
return 0
fi
done
fi

return 1
}
2 changes: 1 addition & 1 deletion generator/default.p9k
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function __p9k_left_prompt_segment() {

# Print the visual identifier and content if any
local visual_identifier
[[ -n "${SEGMENT_ICON}" ]] && visual_identifier="$__P9K_DATA[${STATEFUL_NAME}_VI]${SEGMENT_ICON}%f"
[[ -n "${SEGMENT_ICON}" ]] && visual_identifier="$__P9K_DATA[${STATEFUL_NAME}_VI]${SEGMENT_ICON}"
[[ -n "${content}" ]] && content="${fg}${content}"
[[ -n "${visual_identifier}" && -n "${content}" ]] && visual_identifier="${visual_identifier}${middle_ws}"
echo -n "${visual_identifier}${content}${right_ws}"
Expand Down
6 changes: 3 additions & 3 deletions segments/anaconda/anaconda.spec
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
CONDA_ENV_PATH=/tmp
unset CONDA_PREFIX

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

function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
Expand All @@ -52,7 +52,7 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
unset CONDA_ENV_PATH
local CONDA_PREFIX="test"

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

function testAnacondaSegmentWorks() {
Expand All @@ -66,7 +66,7 @@ function testAnacondaSegmentWorks() {
local CONDA_ENV_PATH=/tmp
local CONDA_PREFIX="test"

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

source shunit2/shunit2
4 changes: 2 additions & 2 deletions segments/aws_eb_env/aws_eb_env.spec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test

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

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

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

rm -fr /tmp/powerlevel9k-test
cd -
Expand Down
10 changes: 5 additions & 5 deletions segments/background_jobs/background_jobs.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function testBackgroundJobsSegmentVerboseAlwaysPrintsZeroWithoutBackgroundJobs()
# Load Powerlevel9k
source segments/background_jobs/background_jobs.p9k

assertEquals "%K{003} %F{000}⚙%f %F{000}0 %k%F{003}%f " "$(__p9k_build_left_prompt)"
assertEquals "%K{003} %F{000}⚙ %F{000}0 %k%F{003}%f " "$(__p9k_build_left_prompt)"
}

function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
Expand All @@ -47,7 +47,7 @@ function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {

# Load Powerlevel9k
source segments/background_jobs/background_jobs.p9k
assertEquals "%K{003} %F{000}⚙%f %k%F{003}%f " "$(__p9k_build_left_prompt)"
assertEquals "%K{003} %F{000}⚙ %k%F{003}%f " "$(__p9k_build_left_prompt)"
}

function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
Expand All @@ -60,7 +60,7 @@ function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
# Load Powerlevel9k
source segments/background_jobs/background_jobs.p9k

assertEquals "%K{003} %F{000}⚙%f %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
assertEquals "%K{003} %F{000}⚙ %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
}

function testBackgroundJobsSegmentWithVerboseMode() {
Expand All @@ -73,7 +73,7 @@ function testBackgroundJobsSegmentWithVerboseMode() {
# Load Powerlevel9k
source segments/background_jobs/background_jobs.p9k

assertEquals "%K{003} %F{000}⚙%f %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
assertEquals "%K{003} %F{000}⚙ %F{000}3 %k%F{003}%f " "$(__p9k_build_left_prompt)"
}

function testBackgroundJobsSegmentWorksWithExpandedMode() {
Expand All @@ -87,7 +87,7 @@ function testBackgroundJobsSegmentWorksWithExpandedMode() {
# Load Powerlevel9k
source segments/background_jobs/background_jobs.p9k

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

source shunit2/shunit2
1 change: 1 addition & 0 deletions segments/battery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ systems without a battery). It is supported on both OSX and Linux.
|`P9K_BATTERY_LOW_THRESHOLD`|`10`|Threshold to consider battery level critical.|
|`P9K_BATTERY_LOW_COLOR`|`"red"`|Color to indicate critically low charge level.|
|`P9K_BATTERY_VERBOSE`|`true`|Display time remaining next to battery level.|
|`P9K_BATTERY_HIDE_ABOVE_THRESHOLD`|`unset`|Threshold from which the battery segment should not be displayed.|

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

Expand Down
Loading

0 comments on commit d4b3867

Please sign in to comment.