spaceship-prompt 4.8.0 → 4.9.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/lib/utils.zsh CHANGED
@@ -151,11 +151,9 @@ spaceship::upsearch() {
151
151
  while [ "$root" ]; do
152
152
  # For every file as an argument
153
153
  for file in "${files[@]}"; do
154
- local filepath="$root/$file"
155
- if [[ -e "$filepath" ]]; then
156
- if [[ -z "$silent" ]]; then
157
- echo "$filepath"
158
- fi
154
+ local filepath="$(find $root -name $file -maxdepth 1 -print -quit)"
155
+ if [[ -n "$filepath" ]]; then
156
+ [[ -z "$silent" ]] && echo "$filepath"
159
157
  return 0
160
158
  fi
161
159
  done
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spaceship-prompt",
3
- "version": "4.8.0",
3
+ "version": "4.9.0",
4
4
  "description": "A Zsh prompt for Astronauts.",
5
5
  "files": [
6
6
  "lib",
@@ -0,0 +1,53 @@
1
+ #
2
+ # Ansible
3
+ #
4
+ # Ansible is a suite of software tools that enables infrastructure as code.
5
+ # Link: https://docs.ansible.com/ansible/latest/index.html
6
+
7
+ # ------------------------------------------------------------------------------
8
+ # Configuration
9
+ # ------------------------------------------------------------------------------
10
+
11
+ SPACESHIP_ANSIBLE_SHOW="${SPACESHIP_ANSIBLE_SHOW=true}"
12
+ SPACESHIP_ANSIBLE_ASYNC="${SPACESHIP_ANSIBLE_ASYNC=true}"
13
+ SPACESHIP_ANSIBLE_PREFIX="${SPACESHIP_ANSIBLE_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
14
+ SPACESHIP_ANSIBLE_SUFFIX="${SPACESHIP_ANSIBLE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
15
+ SPACESHIP_ANSIBLE_SYMBOL="${SPACESHIP_ANSIBLE_SYMBOL="🅐 "}"
16
+ SPACESHIP_ANSIBLE_COLOR="${SPACESHIP_ANSIBLE_COLOR="white"}"
17
+
18
+ # ------------------------------------------------------------------------------
19
+ # Section
20
+ # ------------------------------------------------------------------------------
21
+
22
+ spaceship_ansible() {
23
+ [[ $SPACESHIP_ANSIBLE_SHOW == false ]] && return
24
+
25
+ # Check if ansible is installed
26
+ spaceship::exists ansible || return
27
+
28
+ # Show ansible section only when there are ansible-specific files in current
29
+ # working directory.
30
+ # Here glob qualifiers are used to check if files with specific extension are
31
+ # present in directory. Read more about them here:
32
+ # https://zsh.sourceforge.net/Doc/Release/Expansion.html
33
+ local ansible_configs="$(spaceship::upsearch ansible.cfg .ansible.cfg)"
34
+ local yaml_files="$(echo ?(*.yml|*.yaml)([1]N^/))"
35
+ local detected_playbooks
36
+
37
+ if [[ -n "$yaml_files" ]]; then
38
+ detected_playbooks="$(spaceship::grep -oE "tasks|hosts|roles" $yaml_files)"
39
+ fi
40
+
41
+ [[ -n "$ansible_configs" || -n "$detected_playbooks" ]] || return
42
+
43
+ # Retrieve ansible version
44
+ local ansible_version=$(ansible --version | head -1 | spaceship::grep -oE '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]')
45
+
46
+ # Display ansible section
47
+ spaceship::section \
48
+ --color "$SPACESHIP_ANSIBLE_COLOR" \
49
+ --prefix "$SPACESHIP_ANSIBLE_PREFIX" \
50
+ --suffix "$SPACESHIP_ANSIBLE_SUFFIX" \
51
+ --symbol "$SPACESHIP_ANSIBLE_SYMBOL" \
52
+ "v$ansible_version"
53
+ }
package/sections/dart.zsh CHANGED
@@ -1,6 +1,6 @@
1
-
1
+ #
2
2
  # Dart
3
-
3
+ #
4
4
  # Dart is a client-optimized language for fast apps on any platform
5
5
  # Link: https://dart.dev/
6
6
 
@@ -34,32 +34,24 @@ spaceship_docker() {
34
34
  spaceship::exists docker || return
35
35
 
36
36
  # Better support for docker environment vars: https://docs.docker.com/compose/reference/envvars/
37
- local compose_exists=false
38
37
  if [[ -n "$COMPOSE_FILE" ]]; then
38
+ local compose_path
39
39
  # Use COMPOSE_PATH_SEPARATOR or colon as default
40
40
  local separator=${COMPOSE_PATH_SEPARATOR:-":"}
41
-
42
- # COMPOSE_FILE may have several filenames separated by colon, test all of them
41
+ # COMPOSE_FILE may have several filenames separated by colon, upsearch all of them
43
42
  local filenames=("${(@ps/$separator/)COMPOSE_FILE}")
44
-
45
- for filename in $filenames; do
46
- if [[ ! -f $filename ]]; then
47
- compose_exists=false
48
- break
49
- fi
50
- compose_exists=true
51
- done
43
+ local compose_path="$(spaceship::upsearch -s $filenames)"
52
44
 
53
45
  # Must return if COMPOSE_FILE is present but invalid
54
- [[ "$compose_exists" == false ]] && return
46
+ [[ -n "$compose_path" ]] || return
55
47
  fi
56
48
 
57
49
  local docker_context="$(spaceship_docker_context)"
58
50
  local docker_context_section="$(spaceship::section::render $docker_context)"
59
51
 
60
52
  # Show Docker status only for Docker-specific folders or when connected to external host
61
- local is_docker_project="$(spaceship::upsearch Dockerfile docker-compose.yml .devcontainer/Dockerfile)"
62
- [[ "$compose_exists" == true || -n "$is_docker_project" || -f /.dockerenv || -n $docker_context ]] || return
53
+ local is_docker_project="$(spaceship::upsearch Dockerfile .devcontainer/Dockerfile docker-compose.y*ml)"
54
+ [[ -n "$is_docker_project" || -f /.dockerenv || -n "$docker_context" ]] || return
63
55
 
64
56
  # if docker daemon isn't running you'll get an error saying it can't connect
65
57
  # Note: Declaration and assignment is separated for correctly getting the exit code
@@ -0,0 +1,69 @@
1
+ #
2
+ # Docker Compose
3
+ #
4
+ # Compose is a tool for defining and running multi-container Docker applications.
5
+ # Link: https://docs.docker.com/compose/
6
+
7
+ # ------------------------------------------------------------------------------
8
+ # Configuration
9
+ # ------------------------------------------------------------------------------
10
+
11
+ SPACESHIP_DOCKER_COMPOSE_SHOW="${SPACESHIP_DOCKER_COMPOSE_SHOW=true}"
12
+ SPACESHIP_DOCKER_COMPOSE_ASYNC="${SPACESHIP_DOCKER_COMPOSE_ASYNC=true}"
13
+ SPACESHIP_DOCKER_COMPOSE_PREFIX="${SPACESHIP_DOCKER_COMPOSE_PREFIX="runs "}"
14
+ SPACESHIP_DOCKER_COMPOSE_SUFFIX="${SPACESHIP_DOCKER_COMPOSE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
15
+ SPACESHIP_DOCKER_COMPOSE_SYMBOL="${SPACESHIP_DOCKER_COMPOSE_SYMBOL="🐙 "}"
16
+ SPACESHIP_DOCKER_COMPOSE_COLOR="${SPACESHIP_DOCKER_COMPOSE_COLOR="cyan"}"
17
+ SPACESHIP_DOCKER_COMPOSE_COLOR_UP="${SPACESHIP_DOCKER_COMPOSE_COLOR_UP="green"}"
18
+ SPACESHIP_DOCKER_COMPOSE_COLOR_DOWN="${SPACESHIP_DOCKER_COMPOSE_COLOR_DOWN="red"}"
19
+ SPACESHIP_DOCKER_COMPOSE_COLOR_PAUSED="${SPACESHIP_DOCKER_COMPOSE_COLOR_PAUSED="yellow"}"
20
+
21
+ # ------------------------------------------------------------------------------
22
+ # Utils
23
+ # ------------------------------------------------------------------------------
24
+
25
+ spaceship_docker_compose::paint() {
26
+ local color="$1" text="$2"
27
+ echo -n "%{%F{$color}%}$text%{%f%}"
28
+ }
29
+
30
+ # ------------------------------------------------------------------------------
31
+ # Section
32
+ # ------------------------------------------------------------------------------
33
+
34
+ spaceship_docker_compose() {
35
+ [[ $SPACESHIP_DOCKER_COMPOSE_SHOW == false ]] && return
36
+
37
+ spaceship::exists docker-compose || return
38
+ spaceship::upsearch -s docker-compose.y*ml || return
39
+
40
+ local containers="$(docker-compose ps 2>/dev/null | tail -n+2)"
41
+ [[ -n "$containers" ]] || return
42
+
43
+ local statuses=""
44
+
45
+ while IFS= read -r line; do
46
+ local letter_position=$(echo $line | awk 'match($0,"_"){print RSTART}')
47
+ local letter=$(echo ${line:$letter:1} | tr '[:lower:]' '[:upper:]')
48
+ local color=""
49
+ [[ -z "$letter" ]] && continue
50
+
51
+ if [[ "$line" == *"Up"* ]] || [[ "$line" == *"running"* ]]; then
52
+ color="$SPACESHIP_DOCKER_COMPOSE_COLOR_UP"
53
+ elif [[ "$line" == *"Paused"* ]] || [[ "$line" == *"paused"* ]]; then
54
+ color="$SPACESHIP_DOCKER_COMPOSE_COLOR_PAUSED"
55
+ else
56
+ color="$SPACESHIP_DOCKER_COMPOSE_COLOR_DOWN"
57
+ fi
58
+
59
+ statuses+="$(spaceship_docker_compose::paint $color $letter)"
60
+ done <<< "$containers"
61
+
62
+ spaceship::section \
63
+ --color "$SPACESHIP_DOCKER_COMPOSE_COLOR" \
64
+ --prefix "$SPACESHIP_DOCKER_COMPOSE_PREFIX" \
65
+ --suffix "$SPACESHIP_DOCKER_COMPOSE_SUFFIX" \
66
+ --symbol "$SPACESHIP_DOCKER_COMPOSE_SYMBOL" \
67
+ "$statuses"
68
+ }
69
+
@@ -1,5 +1,5 @@
1
1
  #
2
- # Haskell Stack
2
+ # Haskell
3
3
  #
4
4
  # An advanced, purely functional programming language.
5
5
  # Link: https://www.haskell.org/
@@ -25,12 +25,18 @@ spaceship_haskell() {
25
25
 
26
26
  # If there are stack files in the context
27
27
  local is_haskell_project=$(spaceship::upsearch stack.yaml)
28
- [[ -n "$is_haskell_project" || -n *.hs(#qN^/) ]] || return
29
-
30
- # The command is stack, so do not change this to haskell.
31
- spaceship::exists stack || return
32
-
33
- local haskell_version=$(stack ghc -- --numeric-version --no-install-ghc)
28
+ [[ -n "$is_haskell_project" || -n *.hs(#qN^/) || -n *.cabal(#qN) ]] || return
29
+
30
+ local haskell_version
31
+
32
+ # Extracting Haskell version
33
+ if spaceship::exists cabal; then
34
+ haskell_version=$(ghc -- --numeric-version --no-install-ghc)
35
+ elif spaceship::exists stack; then
36
+ haskell_version=$(stack ghc -- --numeric-version --no-install-ghc)
37
+ else
38
+ return
39
+ fi
34
40
 
35
41
  spaceship::section \
36
42
  --color "$SPACESHIP_HASKELL_COLOR" \
package/sections/perl.zsh CHANGED
@@ -28,7 +28,7 @@ spaceship_perl() {
28
28
  spaceship::exists perl || return
29
29
 
30
30
  # Show only if perl files or composer.json exist in current directory
31
- local is_perl_project="$(spaceship::upsearch META.json META.yml META.yaml .perl-version cpanfile)"
31
+ local is_perl_project="$(spaceship::upsearch META.{json,yml,yaml} .perl-version cpanfile)"
32
32
  [[ -n "$is_perl_project" || -n *.pl(#qN^/) || -n *.pm(#qN^/) ]] || return
33
33
 
34
34
  local perl_version=$(perl -v 2>&1 | awk '/This/ {print $9}' | sed -r 's/[(v]+//g;s/[)]//g')
@@ -0,0 +1,43 @@
1
+ #
2
+ # Pulumi
3
+ #
4
+ # Pulumi automates the repetitive tasks of setting up cloud resources
5
+ # Link: https://www.pulumi.com/
6
+ #
7
+ # This section shows you the current stack and number of resources
8
+ # Link: https://www.pulumi.com/docs/intro/concepts/stack/
9
+
10
+ # ------------------------------------------------------------------------------
11
+ # Configuration
12
+ # ------------------------------------------------------------------------------
13
+
14
+ SPACESHIP_PULUMI_SHOW="${SPACESHIP_PULUMI_SHOW=true}"
15
+ SPACESHIP_PULUMI_ASYNC="${SPACESHIP_PULUMI_ASYNC=true}"
16
+ SPACESHIP_PULUMI_PREFIX="${SPACESHIP_PULUMI_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
17
+ SPACESHIP_PULUMI_SUFFIX="${SPACESHIP_PULUMI_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
18
+ SPACESHIP_PULUMI_SYMBOL="${SPACESHIP_PULUMI_SYMBOL=" "}"
19
+ SPACESHIP_PULUMI_COLOR="${SPACESHIP_PULUMI_COLOR="133"}"
20
+
21
+ # ------------------------------------------------------------------------------
22
+ # Section
23
+ # ----------------------------------------------- -------------------------------
24
+
25
+ spaceship_pulumi() {
26
+ [[ $SPACESHIP_PULUMI_SHOW == false ]] && return
27
+
28
+ spaceship::exists pulumi || return
29
+
30
+ # Show PULUMI Stack when exists
31
+ local pulumi_project=$(spaceship::upsearch Pulumi.y*ml)
32
+ [[ -n "$pulumi_project" || -d .pulumi/stacks ]] || return
33
+
34
+ local pulumi_stack=$(pulumi stack ls 2>/dev/null | sed -n -e '2p' | cut -f1 -d" " | sed s/\*//)
35
+ [[ -z $pulumi_stack ]] && return
36
+
37
+ spaceship::section \
38
+ --color "$SPACESHIP_PULUMI_COLOR" \
39
+ --prefix "$SPACESHIP_PULUMI_PREFIX" \
40
+ --suffix "$SPACESHIP_PULUMI_SUFFIX" \
41
+ --symbol "$SPACESHIP_PULUMI_SYMBOL" \
42
+ "$pulumi_stack"
43
+ }
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.8.0'
11
+ export SPACESHIP_VERSION='4.9.0'
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)
@@ -40,51 +40,54 @@ fi
40
40
 
41
41
  if [ -z "$SPACESHIP_PROMPT_ORDER" ]; then
42
42
  SPACESHIP_PROMPT_ORDER=(
43
- time # Time stamps section
44
- user # Username section
45
- dir # Current directory section
46
- host # Hostname section
47
- git # Git section (git_branch + git_status)
48
- hg # Mercurial section (hg_branch + hg_status)
49
- package # Package version
50
- node # Node.js section
51
- bun # Bun section
52
- deno # Deno section
53
- ruby # Ruby section
54
- python # Python section
55
- elm # Elm section
56
- elixir # Elixir section
57
- xcode # Xcode section
58
- swift # Swift section
59
- golang # Go section
60
- perl # Perl section
61
- php # PHP section
62
- rust # Rust section
63
- haskell # Haskell Stack section
64
- scala # Scala section
65
- java # Java section
66
- lua # Lua section
67
- dart # Dart section
68
- julia # Julia section
69
- crystal # Crystal section
70
- docker # Docker section
71
- aws # Amazon Web Services section
72
- gcloud # Google Cloud Platform section
73
- venv # virtualenv section
74
- conda # conda virtualenv section
75
- dotnet # .NET section
76
- ocaml # OCaml section
77
- kubectl # Kubectl context section
78
- terraform # Terraform workspace section
79
- ibmcloud # IBM Cloud section
80
- nix_shell # Nix shell
81
- exec_time # Execution time
82
- async # Async jobs indicator
83
- line_sep # Line break
84
- battery # Battery level and status
85
- jobs # Background jobs indicator
86
- exit_code # Exit code section
87
- char # Prompt character
43
+ time # Time stamps section
44
+ user # Username section
45
+ dir # Current directory section
46
+ host # Hostname section
47
+ git # Git section (git_branch + git_status)
48
+ hg # Mercurial section (hg_branch + hg_status)
49
+ package # Package version
50
+ node # Node.js section
51
+ bun # Bun section
52
+ deno # Deno section
53
+ ruby # Ruby section
54
+ python # Python section
55
+ elm # Elm section
56
+ elixir # Elixir section
57
+ xcode # Xcode section
58
+ swift # Swift section
59
+ golang # Go section
60
+ perl # Perl section
61
+ php # PHP section
62
+ rust # Rust section
63
+ haskell # Haskell Stack section
64
+ scala # Scala section
65
+ java # Java section
66
+ lua # Lua section
67
+ dart # Dart section
68
+ julia # Julia section
69
+ crystal # Crystal section
70
+ docker # Docker section
71
+ docker_compose # Docker section
72
+ aws # Amazon Web Services section
73
+ gcloud # Google Cloud Platform section
74
+ venv # virtualenv section
75
+ conda # conda virtualenv section
76
+ dotnet # .NET section
77
+ ocaml # OCaml section
78
+ kubectl # Kubectl context section
79
+ ansible # Ansible section
80
+ terraform # Terraform workspace section
81
+ pulumi # Pulumi stack section
82
+ ibmcloud # IBM Cloud section
83
+ nix_shell # Nix shell
84
+ exec_time # Execution time
85
+ async # Async jobs indicator
86
+ line_sep # Line break
87
+ battery # Battery level and status
88
+ jobs # Background jobs indicator
89
+ exit_code # Exit code section
90
+ char # Prompt character
88
91
  )
89
92
  fi
90
93