From 5657fe6ac7d75cac48a386f55e429b716f8d7623 Mon Sep 17 00:00:00 2001 From: Chris Chou Date: Fri, 6 Oct 2017 09:47:37 +1300 Subject: #632: Indicate `Rust` or `(rust)` for rust_version segment only if icon is unavailable --- functions/icons.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index 3a4909f7..be507563 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -77,7 +77,7 @@ case $POWERLEVEL9K_MODE in VCS_GIT_GITLAB_ICON $'\uE20E ' # VCS_HG_ICON $'\uE1C3 ' #  VCS_SVN_ICON '(svn) ' - RUST_ICON '' + RUST_ICON '(rust)' PYTHON_ICON $'\ue63c' #  SWIFT_ICON '' GO_ICON '' @@ -290,7 +290,7 @@ case $POWERLEVEL9K_MODE in VCS_GIT_GITLAB_ICON '' VCS_HG_ICON '' VCS_SVN_ICON '' - RUST_ICON '' + RUST_ICON 'Rust' PYTHON_ICON '' SWIFT_ICON 'Swift' GO_ICON 'Go' -- cgit v1.2.3 From b260adbc1bc68d9729d6eebcfd344f83655bfda9 Mon Sep 17 00:00:00 2001 From: Julien Roy Date: Sat, 24 Mar 2018 11:04:16 +0100 Subject: Added a segment that shows the Java version. --- README.md | 2 ++ functions/icons.zsh | 4 ++++ powerlevel9k.zsh-theme | 9 +++++++++ 3 files changed, 15 insertions(+) (limited to 'functions') diff --git a/README.md b/README.md index 46d8ab61..2686b2e7 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ The segments that are currently available are: * `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg). * **Swift Segments:** * `swift_version` - Show the version number of the installed Swift. +* **Java Segments:** + * `java_version` - Show the current Java version. **Cloud Segments:** * **AWS Segments:** diff --git a/functions/icons.zsh b/functions/icons.zsh index 7124386b..b7da9940 100644 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -87,6 +87,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON '(ssh)' VPN_ICON '(vpn)' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; 'awesome-fontconfig') @@ -158,6 +159,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON '(ssh)' VPN_ICON $'\uF023' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -229,6 +231,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON $'\uF489' #  VPN_ICON '(vpn)' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; *) @@ -300,6 +303,7 @@ case $POWERLEVEL9K_MODE in SSH_ICON '(ssh)' VPN_ICON '(vpn)' KUBERNETES_ICON $'\U2388' # ⎈ + JAVA_ICON $'\U2615' # ☕︎ ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 14d7bd81..e3be9c53 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1433,6 +1433,15 @@ prompt_kubecontext() { fi } +# print Java version number +prompt_java_version() { + local java_version + java_version=$(java -fullversion 2>&1 | cut -d '"' -f 2) + + if [[ -n "$java_version" ]]; then + "$1_prompt_segment" "$0" "$2" "red" "white" "$java_version" "JAVA_ICON" + fi +} ################################################################ # Prompt processing and drawing -- cgit v1.2.3 From 1aee125470cd16add49fb700fbde4691197ae3da Mon Sep 17 00:00:00 2001 From: Guilherme Cassolato Date: Wed, 11 Apr 2018 17:07:24 +0200 Subject: Fixes wrapper slowness in vcs segment --- functions/vcs.zsh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'functions') diff --git a/functions/vcs.zsh b/functions/vcs.zsh index c3e507b9..6a30903e 100644 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -16,8 +16,8 @@ function +vi-git-untracked() { FLAGS+='--ignore-submodules=dirty' fi - if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ - -n $(git status ${FLAGS} | grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then + if [[ $(command git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ + -n $(command git status ${FLAGS} | grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')" VCS_WORKDIR_HALF_DIRTY=true else @@ -29,16 +29,16 @@ function +vi-git-aheadbehind() { local ahead behind branch_name local -a gitstatus - branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) + branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) # for git prior to 1.7 - # ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l) - ahead=$(git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l) + # ahead=$(command git rev-list origin/${branch_name}..HEAD | wc -l) + ahead=$(command git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l) (( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" ) # for git prior to 1.7 - # behind=$(git rev-list HEAD..origin/${branch_name} | wc -l) - behind=$(git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l) + # behind=$(command git rev-list HEAD..origin/${branch_name} | wc -l) + behind=$(command git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l) (( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" ) hook_com[misc]+=${(j::)gitstatus} @@ -48,8 +48,8 @@ function +vi-git-remotebranch() { local remote branch_name # Are we on a remote-tracking branch? - remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} - branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) + remote=${$(command git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} + branch_name=$(command git symbolic-ref --short HEAD 2>/dev/null) hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}" # Always show the remote @@ -65,18 +65,18 @@ function +vi-git-tagname() { if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then # If we are on a tag, append the tagname to the current branch string. local tag - tag=$(git describe --tags --exact-match HEAD 2>/dev/null) + tag=$(command git describe --tags --exact-match HEAD 2>/dev/null) if [[ -n "${tag}" ]] ; then # There is a tag that points to our current commit. Need to determine if we # are also on a branch, or are in a DETACHED_HEAD state. - if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then + if [[ -z $(command git symbolic-ref HEAD 2>/dev/null) ]]; then # DETACHED_HEAD state. We want to append the tag name to the commit hash # and print it. Unfortunately, `vcs_info` blows away the hash when a tag # exists, so we have to manually retrieve it and clobber the branch # string. local revision - revision=$(git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD) + revision=$(command git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD) hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}" else # We are on both a tag and a branch; print both by appending the tag name. @@ -91,8 +91,8 @@ function +vi-git-tagname() { function +vi-git-stash() { local -a stashes - if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then - stashes=$(git stash list 2>/dev/null | wc -l) + if [[ -s $(command git rev-parse --git-dir)/refs/stash ]] ; then + stashes=$(command git stash list 2>/dev/null | wc -l) hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${stashes// /}" fi } @@ -111,7 +111,7 @@ function +vi-hg-bookmarks() { function +vi-vcs-detect-changes() { if [[ "${hook_com[vcs]}" == "git" ]]; then - local remote=$(git ls-remote --get-url 2> /dev/null) + local remote=$(command git ls-remote --get-url 2> /dev/null) if [[ "$remote" =~ "github" ]] then vcs_visual_identifier='VCS_GIT_GITHUB_ICON' elif [[ "$remote" =~ "bitbucket" ]] then -- cgit v1.2.3 From 111d152d48cc92229cb523a992a0ecee740381e7 Mon Sep 17 00:00:00 2001 From: Taras Shpachenko Date: Thu, 12 Apr 2018 13:39:39 +0300 Subject: Add vcs branch name truncating. --- README.md | 23 +++++++++++++++ functions/vcs.zsh | 15 ++++++++++ test/segments/vcs.spec | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) (limited to 'functions') diff --git a/README.md b/README.md index 8b0fc03c..bd3b8318 100644 --- a/README.md +++ b/README.md @@ -637,6 +637,29 @@ from the [Installation](#Installation) section above. | None | None | ![icon_git](https://cloud.githubusercontent.com/assets/1544760/7976092/b5909f80-0a76-11e5-9950-1438b9d72465.gif) | Repository is a git repository | None | None | ![icon_mercurial](https://cloud.githubusercontent.com/assets/1544760/7976090/b5908da6-0a76-11e5-8c91-452b6e73f631.gif) | Repository is a Mercurial repository +You can limit the branch name to a certain length by truncating long names. +Customizations available are: + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_VCS_SHORTEN_LENGTH`|None|This field determines how many characters to show.| +|`POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH`|None|This field determines minimum branch length. Branch name will be truncated if its length greater than this field.| +|`POWERLEVEL9K_VCS_SHORTEN_STRATEGY`|None|This field determines how branch name should be truncated. See the table below for more information.| +|`POWERLEVEL9K_SHORTEN_DELIMITER`|`...`|Delimiter to use in truncated strings. This can be any string you choose, including an empty string if you wish to have no delimiter.| + +| Strategy Name | Description | +|---------------|-------------| +|`truncate_middle`|Truncates the middle part of a branch. E.g. branch name is `1234-super_super_long_branch_name`, then it will truncated to `1234-..._name`, if `POWERLEVEL9K_VCS_SHORTEN_LENGTH=5` is also set (controls the amount of characters to be left).| +|`truncate_from_right`|Just leaves the beginning of a branch name untouched. E.g. branch name will be truncated like so: `1234-...`. How many characters will be untouched is controlled by `POWERLEVEL9K_VCS_SHORTEN_LENGTH`.| + +For example, if you want to truncate `1234-super_super_long_branch_name` to `1234-..` and don't do it with `development`: +```zsh +POWERLEVEL9K_VCS_SHORTEN_LENGTH=4 +POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=11 +POWERLEVEL9K_SHORTEN_STRATEGY="truncate_from_right" +POWERLEVEL9K_VCS_SHORTEN_DELIMITER=".." +``` + ##### vi_mode This segment shows ZSH's current input mode. Note that this is only useful if diff --git a/functions/vcs.zsh b/functions/vcs.zsh index e2e9f3a3..c936f27d 100755 --- a/functions/vcs.zsh +++ b/functions/vcs.zsh @@ -51,6 +51,21 @@ function +vi-git-remotebranch() { remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} branch_name=$(git symbolic-ref --short HEAD 2>/dev/null) + if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then + set_default POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026' + + if [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_LENGTH ]; then + case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in + truncate_middle) + hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER$(echo "${branch_name: -$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")" + ;; + truncate_from_right) + hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER" + ;; + esac + fi + fi + hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}" # Always show the remote #if [[ -n ${remote} ]] ; then diff --git a/test/segments/vcs.spec b/test/segments/vcs.spec index c33b564d..f6474f61 100755 --- a/test/segments/vcs.spec +++ b/test/segments/vcs.spec @@ -78,4 +78,84 @@ function testColorOverridingForUntrackedStateWorks() { unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND } +function testBranchNameTruncatingShortenLength() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=6 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + +function testBranchNameTruncatingMinLength() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=6 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=7 + + assertEquals "%K{green} %F{black} master ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + +function testBranchNameTruncatingShortenStrategy() { + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs) + POWERLEVEL9K_VCS_SHORTEN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=3 + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_from_right" + + FOLDER=/tmp/powerlevel9k-test/vcs-test + mkdir -p $FOLDER + cd $FOLDER + git init 1>/dev/null + touch testfile + + assertEquals "%K{green} %F{black} mas… ? %k%F{green}%f " "$(build_left_prompt)" + + POWERLEVEL9K_VCS_SHORTEN_STRATEGY="truncate_middle" + + assertEquals "%K{green} %F{black} mas…ter ? %k%F{green}%f " "$(build_left_prompt)" + + cd - + rm -fr /tmp/powerlevel9k-test + + unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset POWERLEVEL9K_VCS_SHORTEN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH + unset POWERLEVEL9K_VCS_SHORTEN_STRATEGY +} + source shunit2/source/2.1/src/shunit2 -- cgit v1.2.3 From 557f5993ea7c8ae1fb196bcb21c4e9fd9dee26ce Mon Sep 17 00:00:00 2001 From: Tim Otlik Date: Thu, 17 May 2018 12:08:04 +0200 Subject: add cog symbol to dir segment if folder is /etc* --- functions/icons.zsh | 5 +++++ powerlevel9k.zsh-theme | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index f758d55c..742d8d36 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -71,6 +71,7 @@ case $POWERLEVEL9K_MODE in HOME_SUB_ICON $'\uE18D' #  FOLDER_ICON $'\uE818' #  NETWORK_ICON $'\uE1AD' #  + ETC_ICON $'\uE818' #  LOAD_ICON $'\uE190 ' #  SWAP_ICON $'\uE87D' #  RAM_ICON $'\uE1E2 ' #  @@ -167,6 +168,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON $'\uF015' #  HOME_SUB_ICON $'\uF07C' #  FOLDER_ICON $'\uF115' #  + ETC_ICON $'\uF013' #  NETWORK_ICON $'\uF09E' #  LOAD_ICON $'\uF080 ' #  SWAP_ICON $'\uF0E4' #  @@ -266,6 +268,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  + ETC_ICON $'\uF013' #  NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  @@ -359,6 +362,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON $'\uF015' #  HOME_SUB_ICON $'\uF07C' #  FOLDER_ICON $'\uF115' #  + ETC_ICON $'\uF013' #  NETWORK_ICON $'\uF1EB' #  LOAD_ICON $'\uF080 ' #  SWAP_ICON $'\uF464' #  @@ -452,6 +456,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON '' HOME_SUB_ICON '' FOLDER_ICON '' + ETC_ICON $'\uF013' #  NETWORK_ICON 'IP' LOAD_ICON 'L' SWAP_ICON 'SWP' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8f06866f..b6493fed 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -909,10 +909,13 @@ prompt_dir() { "HOME" "HOME_ICON" "HOME_SUBFOLDER" "HOME_SUB_ICON" "NOT_WRITABLE" "LOCK_ICON" + "ETC" "ETC_ICON" ) local state_path="$(print -P '%~')" local current_state="DEFAULT" - if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then + if [[ $state_path == '/etc'* ]]; then + current_state='ETC' + elif [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then current_state="NOT_WRITABLE" elif [[ $state_path == '~' ]]; then current_state="HOME" -- cgit v1.2.3 From fcea56be5c3da7db8c2c37f143d837eb9fa4986b Mon Sep 17 00:00:00 2001 From: Max O'Cull Date: Fri, 18 May 2018 20:12:05 -0400 Subject: Fix Linux distribution detection --- functions/utilities.zsh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'functions') diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 9a651a0b..61f8cd77 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -106,58 +106,58 @@ case $(uname) in OS='Linux' os_release_id="$(grep -E '^ID=([a-zA-Z]*)' /etc/os-release | cut -d '=' -f 2)" case "$os_release_id" in - "arch") + *arch*) OS_ICON=$(print_icon 'LINUX_ARCH_ICON') ;; - "debian") + *debian*) OS_ICON=$(print_icon 'LINUX_DEBIAN_ICON') ;; - "ubuntu") + *ubuntu*) OS_ICON=$(print_icon 'LINUX_UBUNTU_ICON') ;; - "elementary") + *elementary*) OS_ICON=$(print_icon 'LINUX_ELEMENTARY_ICON') ;; - "fedora") + *fedora*) OS_ICON=$(print_icon 'LINUX_FEDORA_ICON') ;; - "coreos") + *coreos*) OS_ICON=$(print_icon 'LINUX_COREOS_ICON') ;; - "gentoo") + *gentoo*) OS_ICON=$(print_icon 'LINUX_GENTOO_ICON') ;; - "mageia") + *mageia*) OS_ICON=$(print_icon 'LINUX_MAGEIA_ICON') ;; - "centos") + *centos*) OS_ICON=$(print_icon 'LINUX_CENTOS_ICON') ;; - "opensuse"|"tumbleweed") + *opensuse*|*tumbleweed*) OS_ICON=$(print_icon 'LINUX_OPENSUSE_ICON') ;; - "sabayon") + *sabayon*) OS_ICON=$(print_icon 'LINUX_SABAYON_ICON') ;; - "slackware") + *slackware*) OS_ICON=$(print_icon 'LINUX_SLACKWARE_ICON') ;; - "linuxmint") + *linuxmint*) OS_ICON=$(print_icon 'LINUX_MINT_ICON') ;; - "alpine") + *alpine*) OS_ICON=$(print_icon 'LINUX_ALPINE_ICON') ;; - "aosc") + *aosc*) OS_ICON=$(print_icon 'LINUX_AOSC_ICON') ;; - "nixos") + *nixos*) OS_ICON=$(print_icon 'LINUX_NIXOS_ICON') ;; - "devuan") + *devuan*) OS_ICON=$(print_icon 'LINUX_DEVUAN_ICON') ;; - "manjaro") + *manjaro*) OS_ICON=$(print_icon 'LINUX_MANJARO_ICON') ;; *) -- cgit v1.2.3 From a2d8cccd098bc1f739c324623bdabb701e65ba90 Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Tue, 1 May 2018 02:10:26 +0200 Subject: Add a Laravel version segment --- CHANGELOG.md | 6 ++++++ README.md | 1 + functions/icons.zsh | 5 +++++ powerlevel9k.zsh-theme | 12 ++++++++++++ 4 files changed, 24 insertions(+) (limited to 'functions') diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a8842a3..e7e61af6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## next + +### New Segment: `laravel_version` + +Displays the current laravel version. + ## v0.6.4 - `load` segment now has configurable averages. diff --git a/README.md b/README.md index 9b86067f..1e01e915 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ The segments that are currently available are: * `nvm` - Show the version of Node that is currently active, if it differs from the version used by NVM * **PHP Segments:** * `php_version` - Show the current PHP version. + * `laravel_version` - Show the current Laravel version. * [`symfony2_tests`](#symfony2_tests) - Show a ratio of test classes vs code classes for Symfony2. * `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir. * **Python Segments:** diff --git a/functions/icons.zsh b/functions/icons.zsh index 1f90e94f..98c6f13d 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -111,6 +111,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uE184' #  TIME_ICON $'\uE12E' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; 'awesome-fontconfig') @@ -206,6 +207,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uF073 ' #  TIME_ICON $'\uF017 ' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; 'awesome-mapped-fontconfig') @@ -306,6 +308,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uF073 ' #  TIME_ICON $'\uF017 ' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -402,6 +405,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON $'\uF073 ' #  TIME_ICON $'\uF017 ' #  JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON $'\ue73f ' #  ) ;; *) @@ -497,6 +501,7 @@ case $POWERLEVEL9K_MODE in DATE_ICON '' TIME_ICON '' JAVA_ICON $'\U2615' # ☕︎ + LARAVEL_ICON '' ) ;; esac diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index b9119d4c..dde838d9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1109,6 +1109,18 @@ prompt_vpn_ip() { done } +################################################################ +# Segment to display laravel version +prompt_laravel_version() { + local laravel_version="$(php artisan --version 2>/dev/null)" + if [[ -n "${laravel_version}" ]]; then + # Remove unrelevant infos + laravel_version="${laravel_version//Laravel Framework version /}" + + "$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON' + fi +} + ################################################################ # Segment to display load set_default POWERLEVEL9K_LOAD_WHICH 5 -- cgit v1.2.3 From 595bdb4fa35a4dcd424a74297cbae1ee8a20df7a Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sun, 17 Jun 2018 22:57:13 +0200 Subject: Use cog glyph on all modes --- functions/icons.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'functions') diff --git a/functions/icons.zsh b/functions/icons.zsh index 98c6f13d..358f9580 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -71,7 +71,7 @@ case $POWERLEVEL9K_MODE in HOME_SUB_ICON $'\uE18D' #  FOLDER_ICON $'\uE818' #  NETWORK_ICON $'\uE1AD' #  - ETC_ICON $'\uE818' #  + ETC_ICON $'\uE82F' #  LOAD_ICON $'\uE190 ' #  SWAP_ICON $'\uE87D' #  RAM_ICON $'\uE1E2 ' #  @@ -170,7 +170,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON $'\uF015' #  HOME_SUB_ICON $'\uF07C' #  FOLDER_ICON $'\uF115' #  - ETC_ICON $'\uF013' #  + ETC_ICON $'\uF013 ' #  NETWORK_ICON $'\uF09E' #  LOAD_ICON $'\uF080 ' #  SWAP_ICON $'\uF0E4' #  @@ -272,7 +272,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  - ETC_ICON $'\uF013' #  + ETC_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  @@ -464,7 +464,7 @@ case $POWERLEVEL9K_MODE in HOME_ICON '' HOME_SUB_ICON '' FOLDER_ICON '' - ETC_ICON $'\uF013' #  + ETC_ICON $'\u2699' # ⚙ NETWORK_ICON 'IP' LOAD_ICON 'L' SWAP_ICON 'SWP' -- cgit v1.2.3