spaceship-prompt 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ # [4.6.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.5.1...v4.6.0) (2022-10-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * locale dependent test ([#1253](https://github.com/spaceship-prompt/spaceship-prompt/issues/1253)) ([7477dfb](https://github.com/spaceship-prompt/spaceship-prompt/commit/7477dfb601b7fa41975406c53a4e3969899f0471))
7
+ * problem async section not updating ([b72b54a](https://github.com/spaceship-prompt/spaceship-prompt/commit/b72b54ac2ab2babb829ab5d39565961a8591379e))
8
+
9
+
10
+ ### Features
11
+
12
+ * add Dart section ([#1249](https://github.com/spaceship-prompt/spaceship-prompt/issues/1249)) ([f403f2f](https://github.com/spaceship-prompt/spaceship-prompt/commit/f403f2f3f499ee5abb8d8d6b1dac30c5bd8412f1))
13
+ * add Lua section ([#1254](https://github.com/spaceship-prompt/spaceship-prompt/issues/1254)) ([7a3a2e9](https://github.com/spaceship-prompt/spaceship-prompt/commit/7a3a2e94657c90c66c20f7d1627625e851ae9ad6))
14
+
15
+ ## [4.5.1](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.5.0...v4.5.1) (2022-09-30)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **kubectl:** Avoids checking kubectl server version if no context is loaded, stopping potential hangs ([#1246](https://github.com/spaceship-prompt/spaceship-prompt/issues/1246)) ([44819b0](https://github.com/spaceship-prompt/spaceship-prompt/commit/44819b09c3017d0fb42bc22bdcbd05f847b2d915))
21
+ * prepend spaceship root folder to spaceship precompile path ([#1244](https://github.com/spaceship-prompt/spaceship-prompt/issues/1244)) ([6c4623f](https://github.com/spaceship-prompt/spaceship-prompt/commit/6c4623fe9f31ac7b16fb7ebeffaa23b123220ef9))
22
+ * upsearch was exiting when the first file is not found ([#1239](https://github.com/spaceship-prompt/spaceship-prompt/issues/1239)) ([dcfd690](https://github.com/spaceship-prompt/spaceship-prompt/commit/dcfd690f7b7607d05d160b084eb193460e9edf81))
23
+
1
24
  # [4.5.0](https://github.com/spaceship-prompt/spaceship-prompt/compare/v4.4.0...v4.5.0) (2022-09-23)
2
25
 
3
26
 
package/lib/core.zsh CHANGED
@@ -49,7 +49,7 @@ spaceship::core::start() {
49
49
  # USAGE:
50
50
  # spaceship::core::async_callback
51
51
  spaceship::core::async_callback() {
52
- local job="$1" ret="$2" output="$3" exec_time="$4" err="$5" has_next="$6"
52
+ local job="$1" code="$2" output="$3" exec_time="$4" err="$5" has_next="$6"
53
53
  local section="${job#"spaceship_"}" # TODO: Move spaceship_ to a constant
54
54
 
55
55
  # Notify the worker that the job is done
@@ -79,6 +79,13 @@ spaceship::core::async_callback() {
79
79
  ;;
80
80
  *)
81
81
  # Hanlde regular successfully finished jobs
82
+
83
+ # Refresh async section when the last async job has finished
84
+ if [[ "${#SPACESHIP_JOBS}" -eq 0 ]]; then
85
+ spaceship::core::refresh_section "async"
86
+ spaceship::core::render
87
+ fi
88
+
82
89
  # Skip prompt re-rendering if section is empty
83
90
  if [[ "$(spaceship::cache::get $section)" == "$output" ]]; then
84
91
  return
@@ -89,12 +96,6 @@ spaceship::core::async_callback() {
89
96
  ;;
90
97
  esac
91
98
 
92
- # Refresh async section when the last async job has finished
93
- if [[ "${#SPACESHIP_JOBS}" -eq 0 ]]; then
94
- spaceship::core::refresh_section "async"
95
- spaceship::core::render
96
- fi
97
-
98
99
  if [[ "$has_next" == 0 ]]; then
99
100
  spaceship::core::render
100
101
  fi
package/lib/utils.zsh CHANGED
@@ -96,7 +96,7 @@ spaceship::deprecated() {
96
96
  print -P "%B$deprecated%b is deprecated. $message"
97
97
  }
98
98
 
99
- # Display seconds in human readable fromat
99
+ # Display seconds in human readable format
100
100
  # For that use `strftime` and convert the duration (float) to seconds (integer).
101
101
  # USAGE:
102
102
  # spaceship::displaytime <seconds> [precision]
@@ -155,12 +155,14 @@ spaceship::upsearch() {
155
155
  echo "$filepath"
156
156
  fi
157
157
  return 0
158
- elif [[ -d "$root/.git" || -d "$root/.hg" ]]; then
159
- # If we reached the root of repo, return non-zero
160
- return 1
161
158
  fi
162
159
  done
163
160
 
161
+ if [[ -d "$root/.git" || -d "$root/.hg" ]]; then
162
+ # If we reached the root of repo, return non-zero
163
+ return 1
164
+ fi
165
+
164
166
  # Go one level up
165
167
  root="${root%/*}"
166
168
  done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spaceship-prompt",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "A Zsh prompt for Astronauts.",
5
5
  "files": [
6
6
  "lib",
@@ -0,0 +1,40 @@
1
+
2
+ # Dart
3
+
4
+ # Dart is a client-optimized language for fast apps on any platform
5
+ # Link: https://dart.dev/
6
+
7
+ # ------------------------------------------------------------------------------
8
+ # Configuration
9
+ # ------------------------------------------------------------------------------
10
+ SPACESHIP_DART_SHOW="${SPACESHIP_DART_SHOW=true}"
11
+ SPACESHIP_DART_ASYNC="${SPACESHIP_DART_ASYNC=true}"
12
+ SPACESHIP_DART_PREFIX="${SPACESHIP_DART_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
13
+ SPACESHIP_DART_SUFFIX="${SPACESHIP_DART_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
14
+ SPACESHIP_DART_SYMBOL="${SPACESHIP_DART_SYMBOL="🎯 "}"
15
+ SPACESHIP_DART_COLOR="${SPACESHIP_DART_COLOR="blue"}"
16
+
17
+ # ------------------------------------------------------------------------------
18
+ # Section
19
+ # ------------------------------------------------------------------------------
20
+
21
+ spaceship_dart() {
22
+ [[ $SPACESHIP_DART_SHOW == false ]] && return
23
+ spaceship::exists dart || return
24
+
25
+ local is_dart_project="$(spaceship::upsearch pubspec.yaml pubspec.yml pubspec.lock dart_tool)"
26
+ [[ -n "$is_dart_project" || -n *.dart(#qN^/) ]] || return
27
+
28
+ # The Dart binary can be installed directly as 'dart-sdk' or as bundle via Flutter
29
+ # The version can have the following patterns:
30
+ # dart-sdk > Dart SDK version: 2.19.0-edge.efb509c114dcaf54d0a011f717b48893d71ec9c3 (be) (Thu Sep 29 01:58:56 2022 +0000) on "macos_x64"
31
+ # flutter bundle > Dart SDK version: 2.18.1 (stable) (Tue Sep 13 11:42:55 2022 +0200) on "macos_x64"
32
+ local dart_version=$(dart --version | awk '{sub(/-.*/, "", $4); print $4}')
33
+
34
+ spaceship::section \
35
+ --color "$SPACESHIP_DART_COLOR" \
36
+ --prefix "$SPACESHIP_DART_PREFIX" \
37
+ --suffix "$SPACESHIP_DART_SUFFIX" \
38
+ --symbol "${SPACESHIP_DART_SYMBOL}" \
39
+ "v${dart_version}"
40
+ }
@@ -25,6 +25,11 @@ spaceship_kubectl_version() {
25
25
 
26
26
  spaceship::exists kubectl || return
27
27
 
28
+ # kubectl can hang for upwards of 10 seconds if a context isn't loaded, this avoids the unnecessary server version
29
+ # check if a context isn't loaded, avoiding the issue entirely.
30
+ local kube_context=$(kubectl config current-context 2>/dev/null)
31
+ [[ -z $kube_context ]] && return
32
+
28
33
  # if kubectl can't connect kubernetes cluster, kubernetes version section will be not shown
29
34
  local kubectl_version=$(kubectl version --short 2>/dev/null | grep "Server Version" | sed 's/Server Version: \(.*\)/\1/')
30
35
  [[ -z $kubectl_version ]] && return
@@ -0,0 +1,34 @@
1
+ # Lua
2
+ #
3
+ # Lua is a powerful, efficient, lightweight, embeddable scripting language
4
+ # Link: https://lua.org/
5
+
6
+ # ------------------------------------------------------------------------------
7
+ # Configuration
8
+ # ------------------------------------------------------------------------------
9
+ SPACESHIP_LUA_SHOW="${SPACESHIP_LUA_SHOW=true}"
10
+ SPACESHIP_LUA_ASYNC="${SPACESHIP_LUA_ASYNC=true}"
11
+ SPACESHIP_LUA_PREFIX="${SPACESHIP_LUA_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
12
+ SPACESHIP_LUA_SUFFIX="${SPACESHIP_LUA_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
13
+ SPACESHIP_LUA_SYMBOL="${SPACESHIP_LUA_SYMBOL="🌙 "}"
14
+ SPACESHIP_LUA_COLOR="${SPACESHIP_LUA_COLOR="cyan"}"
15
+
16
+ # ------------------------------------------------------------------------------
17
+ # Section(s)
18
+ # ------------------------------------------------------------------------------
19
+ spaceship_lua() {
20
+ [[ $SPACESHIP_LUA_SHOW == false ]] && return
21
+ spaceship::exists lua || return
22
+
23
+ local is_lua_project="$(spaceship::upsearch .lua-version lua)"
24
+ [[ -n "$is_lua_project" || -n *.lua(#qN^/) ]] || return
25
+
26
+ local lua_version=$(lua -v | awk '{print $2}')
27
+
28
+ spaceship::section \
29
+ --color "$SPACESHIP_LUA_COLOR" \
30
+ --prefix "$SPACESHIP_LUA_PREFIX" \
31
+ --suffix "$SPACESHIP_LUA_SUFFIX" \
32
+ --symbol "${SPACESHIP_LUA_SYMBOL}" \
33
+ "v${lua_version}"
34
+ }
package/spaceship.zsh CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  # Current version of Spaceship
9
9
  # Useful for issue reporting
10
- export SPACESHIP_VERSION='4.5.0'
10
+ export SPACESHIP_VERSION='4.6.0'
11
11
 
12
12
  # Determination of Spaceship working directory
13
13
  # https://git.io/vdBH7
@@ -57,6 +57,8 @@ if [ -z "$SPACESHIP_PROMPT_ORDER" ]; then
57
57
  rust # Rust section
58
58
  haskell # Haskell Stack section
59
59
  java # Java section
60
+ lua # Lua section
61
+ dart # Dart section
60
62
  julia # Julia section
61
63
  crystal # Crystal section
62
64
  docker # Docker section
@@ -119,7 +121,7 @@ for lib in "${SPACESHIP_LIBS[@]}"; do
119
121
  done
120
122
 
121
123
  # Load and precompile this file
122
- spaceship::precompile "$0"
124
+ spaceship::precompile "$SPACESHIP_ROOT/$0"
123
125
 
124
126
  # ------------------------------------------------------------------------------
125
127
  # BACKWARD COMPATIBILITY WARNINGS