spaceship-prompt 4.22.0 → 4.22.2
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/README.md +2 -2
- package/lib/cli.zsh +5 -0
- package/lib/extract.zsh +12 -12
- package/package.json +1 -1
- package/sections/dotnet.zsh +1 -1
- package/sections/package.zsh +6 -6
- package/spaceship.zsh +1 -1
package/README.md
CHANGED
|
@@ -94,11 +94,11 @@ Before we begin, let's make sure you have the following installed:
|
|
|
94
94
|
|
|
95
95
|
- [Zsh](http://www.zsh.org/) (v5.2 or recent) must be installed. Run the following command to check your version of Zsh:
|
|
96
96
|
```zsh
|
|
97
|
-
echo $ZSH_VERSION
|
|
97
|
+
echo $ZSH_VERSION # 5.8.1
|
|
98
98
|
```
|
|
99
99
|
- [Powerline Font](https://github.com/powerline/fonts) or [Nerd Font](https://www.nerdfonts.com/) (even better) must be installed and used in your terminal. [Fira Code](https://github.com/tonsky/FiraCode) is a popular choice. To check if Powerline Font works for you, run:
|
|
100
100
|
```zsh
|
|
101
|
-
echo -e "\xee\x82\xa0"
|
|
101
|
+
echo -e "\xee\x82\xa0" #
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
## 🚀 Installation
|
package/lib/cli.zsh
CHANGED
package/lib/extract.zsh
CHANGED
|
@@ -6,33 +6,33 @@
|
|
|
6
6
|
# ------------------------------------------------------------------------------
|
|
7
7
|
|
|
8
8
|
spaceship::extract::python() {
|
|
9
|
-
local imports=$1 load=$2; shift
|
|
9
|
+
local imports=$1 load=$2 file=$3; shift 3
|
|
10
10
|
local keys=("$@")
|
|
11
|
-
python -c "import $imports, functools; data=$load; print(next(filter(None, map(lambda key: functools.reduce(lambda obj, key: obj[key] if key in obj else {}, key.split('.'), data), ['${(j|','|)keys}'])), None))" 2>/dev/null
|
|
11
|
+
python -c "import sys, $imports, functools; data=$load; print(next(filter(None, map(lambda key: functools.reduce(lambda obj, key: obj[key] if key in obj else {}, key.split('.'), data), ['${(j|','|)keys}'])), None))" "$file" 2>/dev/null
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
spaceship::extract::python::yaml() {
|
|
15
15
|
local file=$1; shift
|
|
16
|
-
spaceship::extract::python yaml "yaml.safe_load(open(
|
|
16
|
+
spaceship::extract::python yaml "yaml.safe_load(open(sys.argv[1]))" "$file" "$@"
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
spaceship::extract::python::json() {
|
|
20
20
|
local file=$1; shift
|
|
21
|
-
spaceship::extract::python json "json.load(open(
|
|
21
|
+
spaceship::extract::python json "json.load(open(sys.argv[1]))" "$file" "$@"
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
spaceship::extract::python::toml() {
|
|
25
25
|
local file=$1; shift
|
|
26
|
-
local import py_version
|
|
26
|
+
local import py_version=${(@)$(python3 -V 2>&1)[2]}
|
|
27
27
|
autoload is-at-least
|
|
28
28
|
# Python 3.11 added tomllib in the stdlib.
|
|
29
29
|
# Previous versions require the tomli package
|
|
30
|
-
if is-at-least 3.11 "$py_version"
|
|
30
|
+
if is-at-least 3.11 "$py_version"; then
|
|
31
31
|
import=tomllib
|
|
32
32
|
else
|
|
33
33
|
import=tomli
|
|
34
34
|
fi
|
|
35
|
-
spaceship::extract::python "$import" "$import.load(open(
|
|
35
|
+
spaceship::extract::python "$import" "$import.load(open(sys.argv[1], 'rb'))" "$file" "$@"
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
spaceship::extract::jq() {
|
|
@@ -42,25 +42,25 @@ spaceship::extract::jq() {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
spaceship::extract::ruby() {
|
|
45
|
-
local import=$1 load=$2; shift
|
|
45
|
+
local import=$1 load=$2 file=$3; shift 3
|
|
46
46
|
local keys=("$@")
|
|
47
|
-
ruby -r "$import" -e "puts ['${(j|','|)keys}'].map { |key| key.split('.').reduce($load) { |obj, key| obj[key] } }.find(&:itself)" 2>/dev/null
|
|
47
|
+
ruby -r "$import" -e "puts ['${(j|','|)keys}'].map { |key| key.split('.').reduce($load) { |obj, key| obj[key] } }.find(&:itself)" -- "$file" 2>/dev/null
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
spaceship::extract::ruby::yaml() {
|
|
51
51
|
local file=$1; shift
|
|
52
|
-
spaceship::extract::ruby 'yaml' "YAML
|
|
52
|
+
spaceship::extract::ruby 'yaml' "YAML.safe_load(File.read(ARGV[0]))" "$file" "$@"
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
spaceship::extract::ruby::json() {
|
|
56
56
|
local file=$1; shift
|
|
57
|
-
spaceship::extract::ruby 'json' "JSON::load(File.read(
|
|
57
|
+
spaceship::extract::ruby 'json' "JSON::load(File.read(ARGV[0]))" "$file" "$@"
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
spaceship::extract::node::json() {
|
|
61
61
|
local file=$1; shift
|
|
62
62
|
local keys=("$@")
|
|
63
|
-
node -p "['${(j|','|)keys}'].map(s => s.split('.').reduce((obj, key) => obj[key], require('
|
|
63
|
+
node -p "['${(j|','|)keys}'].map(s => s.split('.').reduce((obj, key) => obj[key], require(require('path').resolve(process.argv[1])))).find(Boolean)" -- "$file" 2>/dev/null
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
# Read data file with dot notation (JSON, YAML, TOML, XML). Additional keys
|
package/package.json
CHANGED
package/sections/dotnet.zsh
CHANGED
|
@@ -26,7 +26,7 @@ spaceship_dotnet() {
|
|
|
26
26
|
[[ $SPACESHIP_DOTNET_SHOW == false ]] && return
|
|
27
27
|
|
|
28
28
|
local is_dotnet_project="$(spaceship::upsearch project.json global.json paket.dependencies)"
|
|
29
|
-
[[ -n "$is_dotnet_project" || -n *.(cs|fs|x)proj(#qN^/) || -n *.sln(#qN^/) ]] || return
|
|
29
|
+
[[ -n "$is_dotnet_project" || -n *.(cs|fs|x)proj(#qN^/) || -n *.sln(x|)(#qN^/) ]] || return
|
|
30
30
|
|
|
31
31
|
spaceship::exists dotnet || return
|
|
32
32
|
|
package/sections/package.zsh
CHANGED
|
@@ -38,8 +38,8 @@ spaceship_package::npm() {
|
|
|
38
38
|
|
|
39
39
|
local package_json=$(spaceship::upsearch package.json) || return
|
|
40
40
|
|
|
41
|
-
local package_version="$(spaceship::extract --json $package_json version)"
|
|
42
|
-
local is_private_package="$(spaceship::extract --json $package_json private)"
|
|
41
|
+
local package_version="$(spaceship::extract --json "$package_json" version)"
|
|
42
|
+
local is_private_package="$(spaceship::extract --json "$package_json" private)"
|
|
43
43
|
|
|
44
44
|
if [[ "$SPACESHIP_PACKAGE_SHOW_PRIVATE" == false && "$is_private_package" == true ]]; then
|
|
45
45
|
return 0
|
|
@@ -60,7 +60,7 @@ spaceship_package::lerna() {
|
|
|
60
60
|
|
|
61
61
|
local lerna_json=$(spaceship::upsearch lerna.json) || return
|
|
62
62
|
|
|
63
|
-
local package_version="$(spaceship::extract --json $lerna_json version)"
|
|
63
|
+
local package_version="$(spaceship::extract --json "$lerna_json" version)"
|
|
64
64
|
|
|
65
65
|
if [[ "$package_version" == "independent" ]]; then
|
|
66
66
|
package_version="($package_version)"
|
|
@@ -86,7 +86,7 @@ spaceship_package::composer() {
|
|
|
86
86
|
|
|
87
87
|
local composer_json=$(spaceship::upsearch composer.json) || return
|
|
88
88
|
|
|
89
|
-
spaceship::extract --json $composer_json "version"
|
|
89
|
+
spaceship::extract --json "$composer_json" "version"
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
spaceship_package::julia() {
|
|
@@ -94,7 +94,7 @@ spaceship_package::julia() {
|
|
|
94
94
|
|
|
95
95
|
local project_toml=$(spaceship::upsearch Project.toml) || return
|
|
96
96
|
|
|
97
|
-
spaceship::extract --toml $project_toml "version"
|
|
97
|
+
spaceship::extract --toml "$project_toml" "version"
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
spaceship_package::maven() {
|
|
@@ -131,7 +131,7 @@ spaceship_package::dart() {
|
|
|
131
131
|
|
|
132
132
|
local pubspec_file=$(spaceship::upsearch pubspec.yaml pubspec.yml) || return
|
|
133
133
|
|
|
134
|
-
spaceship::extract --yaml $pubspec_file "version"
|
|
134
|
+
spaceship::extract --yaml "$pubspec_file" "version"
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
# ------------------------------------------------------------------------------
|
package/spaceship.zsh
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
# Current version of Spaceship
|
|
10
10
|
# Useful for issue reporting
|
|
11
|
-
export SPACESHIP_VERSION='4.22.
|
|
11
|
+
export SPACESHIP_VERSION='4.22.2'
|
|
12
12
|
|
|
13
13
|
# Set SPACESHIP_ROOT if it isn't defined yet or if the directory does
|
|
14
14
|
# not exist anymore (e.g. after an update to a newer version)
|