forked from spaceship-prompt/spaceship-prompt
-
Notifications
You must be signed in to change notification settings - Fork 12
/
spaceship.zsh
1295 lines (1072 loc) · 42.9 KB
/
spaceship.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Spaceship ZSH Theme
#
# Author: Denys Dovhan, denysdovhan.com
# License: MIT
# https://github.com/denysdovhan/spaceship-zsh-theme
# ------------------------------------------------------------------------------
# CONFIGURATION
# The default configuration that can be overridden in .zshrc
# ------------------------------------------------------------------------------
NEWLINE='
'
# ORDER
if [ ! -n "$SPACESHIP_PROMPT_ORDER" ]; then
SPACESHIP_PROMPT_ORDER=(
time
user
host
dir
git
hg
package
node
ruby
elixir
xcode
swift
golang
php
rust
haskell
julia
docker
aws
venv
conda
pyenv
dotnet
ember
kubecontext
exec_time
line_sep
battery
vi_mode
jobs
exit_code
char
)
fi
# PROMPT
SPACESHIP_PROMPT_SYMBOL="${SPACESHIP_PROMPT_SYMBOL:="➜"}"
SPACESHIP_PROMPT_ADD_NEWLINE="${SPACESHIP_PROMPT_ADD_NEWLINE:=true}"
SPACESHIP_PROMPT_SEPARATE_LINE="${SPACESHIP_PROMPT_SEPARATE_LINE:=true}"
SPACESHIP_PROMPT_PREFIXES_SHOW="${SPACESHIP_PROMPT_PREFIXES_SHOW:=true}"
SPACESHIP_PROMPT_SUFFIXES_SHOW="${SPACESHIP_PROMPT_SUFFIXES_SHOW:=true}"
SPACESHIP_PROMPT_DEFAULT_PREFIX="${SPACESHIP_PROMPT_DEFAULT_PREFIX:="via "}"
SPACESHIP_PROMPT_DEFAULT_SUFFIX="${SPACESHIP_PROMPT_DEFAULT_SUFFIX:=" "}"
# TIME
SPACESHIP_TIME_SHOW="${SPACESHIP_TIME_SHOW:=false}"
SPACESHIP_TIME_PREFIX="${SPACESHIP_TIME_PREFIX:="at "}"
SPACESHIP_TIME_SUFFIX="${SPACESHIP_TIME_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_TIME_FORMAT="${SPACESHIP_TIME_FORMAT:=false}"
SPACESHIP_TIME_12HR="${SPACESHIP_TIME_12HR:=false}"
SPACESHIP_TIME_COLOR="${SPACESHIP_TIME_COLOR:="yellow"}"
# USER
SPACESHIP_USER_SHOW="${SPACESHIP_USER_SHOW:=true}"
SPACESHIP_USER_PREFIX="${SPACESHIP_USER_PREFIX:="with "}"
SPACESHIP_USER_SUFFIX="${SPACESHIP_USER_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_USER_COLOR="${SPACESHIP_USER_COLOR:="yellow"}"
SPACESHIP_USER_COLOR_ROOT="${SPACESHIP_USER_COLOR_ROOT:="red"}"
# HOST
SPACESHIP_HOST_SHOW="${SPACESHIP_HOST_SHOW:=true}"
SPACESHIP_HOST_PREFIX="${SPACESHIP_HOST_PREFIX:="at "}"
SPACESHIP_HOST_SUFFIX="${SPACESHIP_HOST_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_HOST_COLOR="${SPACESHIP_HOST_COLOR:="green"}"
# DIR
SPACESHIP_DIR_SHOW="${SPACESHIP_DIR_SHOW:=true}"
SPACESHIP_DIR_PREFIX="${SPACESHIP_DIR_PREFIX:="in "}"
SPACESHIP_DIR_SUFFIX="${SPACESHIP_DIR_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_DIR_TRUNC="${SPACESHIP_DIR_TRUNC:=3}"
SPACESHIP_DIR_COLOR="${SPACESHIP_DIR_COLOR:="cyan"}"
# GIT
SPACESHIP_GIT_SHOW="${SPACESHIP_GIT_SHOW:=true}"
SPACESHIP_GIT_PREFIX="${SPACESHIP_GIT_PREFIX:="on "}"
SPACESHIP_GIT_SUFFIX="${SPACESHIP_GIT_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_GIT_SYMBOL="${SPACESHIP_GIT_SYMBOL:=" "}"
# GIT BRANCH
SPACESHIP_GIT_BRANCH_SHOW="${SPACESHIP_GIT_BRANCH_SHOW:=true}"
SPACESHIP_GIT_BRANCH_PREFIX="${SPACESHIP_GIT_BRANCH_PREFIX:="$SPACESHIP_GIT_SYMBOL"}"
SPACESHIP_GIT_BRANCH_SUFFIX="${SPACESHIP_GIT_BRANCH_SUFFIX:=""}"
SPACESHIP_GIT_BRANCH_COLOR="${SPACESHIP_GIT_BRANCH_COLOR:="magenta"}"
# GIT STATUS
SPACESHIP_GIT_STATUS_SHOW="${SPACESHIP_GIT_STATUS_SHOW:=true}"
SPACESHIP_GIT_STATUS_PREFIX="${SPACESHIP_GIT_STATUS_PREFIX:=" ["}"
SPACESHIP_GIT_STATUS_SUFFIX="${SPACESHIP_GIT_STATUS_SUFFIX:="]"}"
SPACESHIP_GIT_STATUS_COLOR="${SPACESHIP_GIT_STATUS_COLOR:="red"}"
SPACESHIP_GIT_STATUS_UNTRACKED="${SPACESHIP_GIT_STATUS_UNTRACKED:="?"}"
SPACESHIP_GIT_STATUS_ADDED="${SPACESHIP_GIT_STATUS_ADDED:="+"}"
SPACESHIP_GIT_STATUS_MODIFIED="${SPACESHIP_GIT_STATUS_MODIFIED:="!"}"
SPACESHIP_GIT_STATUS_RENAMED="${SPACESHIP_GIT_STATUS_RENAMED:="»"}"
SPACESHIP_GIT_STATUS_DELETED="${SPACESHIP_GIT_STATUS_DELETED:="✘"}"
SPACESHIP_GIT_STATUS_STASHED="${SPACESHIP_GIT_STATUS_STASHED:="$"}"
SPACESHIP_GIT_STATUS_UNMERGED="${SPACESHIP_GIT_STATUS_UNMERGED:="="}"
SPACESHIP_GIT_STATUS_AHEAD="${SPACESHIP_GIT_STATUS_AHEAD:="⇡"}"
SPACESHIP_GIT_STATUS_BEHIND="${SPACESHIP_GIT_STATUS_BEHIND:="⇣"}"
SPACESHIP_GIT_STATUS_DIVERGED="${SPACESHIP_GIT_STATUS_DIVERGED:="⇕"}"
# MERCURIAL
SPACESHIP_HG_SHOW="${SPACESHIP_HG_SHOW:=true}"
SPACESHIP_HG_PREFIX="${SPACESHIP_HG_PREFIX:="on "}"
SPACESHIP_HG_SUFFIX="${SPACESHIP_HG_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_HG_SYMBOL="${SPACESHIP_HG_SYMBOL:="☿ "}"
# MERCURIAL BRANCH
SPACESHIP_HG_BRANCH_SHOW="${SPACESHIP_HG_BRANCH_SHOW:=true}"
SPACESHIP_HG_BRANCH_PREFIX="${SPACESHIP_HG_BRANCH_PREFIX:="$SPACESHIP_HG_SYMBOL"}"
SPACESHIP_HG_BRANCH_SUFFIX="${SPACESHIP_HG_BRANCH_SUFFIX:=""}"
SPACESHIP_HG_BRANCH_COLOR="${SPACESHIP_HG_BRANCH_COLOR:="magenta"}"
# MERCURIAL STATUS
SPACESHIP_HG_STATUS_SHOW="${SPACESHIP_HG_STATUS_SHOW:=true}"
SPACESHIP_HG_STATUS_PREFIX="${SPACESHIP_HG_STATUS_PREFIX:=" ["}"
SPACESHIP_HG_STATUS_SUFFIX="${SPACESHIP_HG_STATUS_SUFFIX:="]"}"
SPACESHIP_HG_STATUS_COLOR="${SPACESHIP_HG_STATUS_COLOR:="red"}"
SPACESHIP_HG_STATUS_UNTRACKED="${SPACESHIP_HG_STATUS_UNTRACKED:="?"}"
SPACESHIP_HG_STATUS_ADDED="${SPACESHIP_HG_STATUS_ADDED:="+"}"
SPACESHIP_HG_STATUS_MODIFIED="${SPACESHIP_HG_STATUD_MODIFIED:="!"}"
SPACESHIP_HG_STATUS_DELETED="${SPACESHIP_HG_STATUS_DELETED:="✘"}"
# PACKAGE
SPACESHIP_PACKAGE_SHOW="${SPACESHIP_PACKAGE_SHOW:=true}"
SPACESHIP_PACKAGE_PREFIX="${SPACESHIP_PACKAGE_PREFIX:="is "}"
SPACESHIP_PACKAGE_SUFFIX="${SPACESHIP_PACKAGE_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_PACKAGE_SYMBOL="${SPACESHIP_PACKAGE_SYMBOL:="📦 "}"
SPACESHIP_PACKAGE_COLOR="${SPACESHIP_PACKAGE_COLOR:="red"}"
# NODE
SPACESHIP_NODE_SHOW="${SPACESHIP_NODE_SHOW:=true}"
SPACESHIP_NODE_PREFIX="${SPACESHIP_NODE_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_NODE_SUFFIX="${SPACESHIP_NODE_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_NODE_SYMBOL="${SPACESHIP_NODE_SYMBOL:="⬢ "}"
SPACESHIP_NODE_DEFAULT_VERSION="${SPACESHIP_NODE_DEFAULT_VERSION:=""}"
SPACESHIP_NODE_COLOR="${SPACESHIP_NODE_COLOR:="green"}"
# RUBY
SPACESHIP_RUBY_SHOW="${SPACESHIP_RUBY_SHOW:=true}"
SPACESHIP_RUBY_PREFIX="${SPACESHIP_RUBY_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_RUBY_SUFFIX="${SPACESHIP_RUBY_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_RUBY_SYMBOL="${SPACESHIP_RUBY_SYMBOL:="💎 "}"
SPACESHIP_RUBY_COLOR="${SPACESHIP_RUBY_COLOR:="red"}"
# ELIXIR
SPACESHIP_ELIXIR_SHOW="${SPACESHIP_ELIXIR_SHOW:=true}"
SPACESHIP_ELIXIR_PREFIX="${SPACESHIP_ELIXIR_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_ELIXIR_SUFFIX="${SPACESHIP_ELIXIR_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_ELIXIR_SYMBOL="${SPACESHIP_ELIXIR_SYMBOL:="💧 "}"
SPACESHIP_ELIXIR_DEFAULT_VERSION="${SPACESHIP_ELIXIR_DEFAULT_VERSION:=""}"
SPACESHIP_ELIXIR_COLOR="${SPACESHIP_ELIXIR_COLOR:="magenta"}"
# XCODE
SPACESHIP_XCODE_SHOW_LOCAL="${SPACESHIP_XCODE_SHOW_LOCAL:=true}"
SPACESHIP_XCODE_SHOW_GLOBAL="${SPACESHIP_XCODE_SHOW_GLOBAL:=false}"
SPACESHIP_XCODE_PREFIX="${SPACESHIP_XCODE_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_XCODE_SUFFIX="${SPACESHIP_XCODE_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_XCODE_SYMBOL="${SPACESHIP_XCODE_SYMBOL:="🛠 "}"
SPACESHIP_XCODE_COLOR="${SPACESHIP_XCODE_COLOR:="blue"}"
# SWIFT
SPACESHIP_SWIFT_SHOW_LOCAL="${SPACESHIP_SWIFT_SHOW_LOCAL:=true}"
SPACESHIP_SWIFT_SHOW_GLOBAL="${SPACESHIP_SWIFT_SHOW_GLOBAL:=false}"
SPACESHIP_SWIFT_PREFIX="${SPACESHIP_SWIFT_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_SWIFT_SUFFIX="${SPACESHIP_SWIFT_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_SWIFT_SYMBOL="${SPACESHIP_SWIFT_SYMBOL:="🐦 "}"
SPACESHIP_SWIFT_COLOR="${SPACESHIP_SWIFT_COLOR:="yellow"}"
# GOLANG
SPACESHIP_GOLANG_SHOW="${SPACESHIP_GOLANG_SHOW:=true}"
SPACESHIP_GOLANG_PREFIX="${SPACESHIP_GOLANG_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_GOLANG_SUFFIX="${SPACESHIP_GOLANG_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_GOLANG_SYMBOL="${SPACESHIP_GOLANG_SYMBOL:="🐹 "}"
SPACESHIP_GOLANG_COLOR="${SPACESHIP_GOLANG_COLOR:="cyan"}"
# PHP
SPACESHIP_PHP_SHOW="${SPACESHIP_PHP_SHOW:=true}"
SPACESHIP_PHP_PREFIX="${SPACESHIP_PHP_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_PHP_SUFFIX="${SPACESHIP_PHP_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_PHP_SYMBOL="${SPACESHIP_PHP_SYMBOL:="🐘 "}"
SPACESHIP_PHP_COLOR="${SPACESHIP_PHP_COLOR:="blue"}"
# RUST
SPACESHIP_RUST_SHOW="${SPACESHIP_RUST_SHOW:=true}"
SPACESHIP_RUST_PREFIX="${SPACESHIP_RUST_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_RUST_SUFFIX="${SPACESHIP_RUST_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_RUST_SYMBOL="${SPACESHIP_RUST_SYMBOL:="𝗥 "}"
SPACESHIP_RUST_COLOR="${SPACESHIP_RUST_COLOR:="red"}"
# HASKELL
SPACESHIP_HASKELL_SHOW="${SPACESHIP_HASKELL_SHOW:=true}"
SPACESHIP_HASKELL_PREFIX="${SPACESHIP_HASKELL_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_HASKELL_SUFFIX="${SPACESHIP_HASKELL_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_HASKELL_SYMBOL="${SPACESHIP_HASKELL_SYMBOL:="λ "}"
SPACESHIP_HASKELL_COLOR="${SPACESHIP_HASKELL_COLOR:="red"}"
# JULIA
SPACESHIP_JULIA_SHOW="${SPACESHIP_JULIA_SHOW:=true}"
SPACESHIP_JULIA_PREFIX="${SPACESHIP_JULIA_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_JULIA_SUFFIX="${SPACESHIP_JULIA_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_JULIA_SYMBOL="${SPACESHIP_JULIA_SYMBOL:="ஃ "}"
SPACESHIP_JULIA_COLOR="${SPACESHIP_JULIA_COLOR:="green"}"
# DOCKER
SPACESHIP_DOCKER_SHOW="${SPACESHIP_DOCKER_SHOW:=true}"
SPACESHIP_DOCKER_PREFIX="${SPACESHIP_DOCKER_PREFIX:="on "}"
SPACESHIP_DOCKER_SUFFIX="${SPACESHIP_DOCKER_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_DOCKER_SYMBOL="${SPACESHIP_DOCKER_SYMBOL:="🐳 "}"
SPACESHIP_DOCKER_COLOR="${SPACESHIP_DOCKER_COLOR:="cyan"}"
# VENV
SPACESHIP_VENV_SHOW="${SPACESHIP_VENV_SHOW:=true}"
SPACESHIP_VENV_PREFIX="${SPACESHIP_VENV_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_VENV_SUFFIX="${SPACESHIP_VENV_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_VENV_COLOR="${SPACESHIP_VENV_COLOR:="blue"}"
# CONDA
SPACESHIP_CONDA_SHOW="${SPACESHIP_CONDA_SHOW:=true}"
SPACESHIP_CONDA_PREFIX="${SPACESHIP_CONDA_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_CONDA_SUFFIX="${SPACESHIP_CONDA_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_CONDA_SYMBOL="${SPACESHIP_CONDA_SYMBOL:="🅒 "}"
SPACESHIP_CONDA_COLOR="${SPACESHIP_CONDA_COLOR:="blue"}"
# PYENV
SPACESHIP_PYENV_SHOW="${SPACESHIP_PYENV_SHOW:=true}"
SPACESHIP_PYENV_PREFIX="${SPACESHIP_PYENV_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_PYENV_SUFFIX="${SPACESHIP_PYENV_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_PYENV_SYMBOL="${SPACESHIP_PYENV_SYMBOL:="🐍 "}"
SPACESHIP_PYENV_COLOR="${SPACESHIP_PYENV_COLOR:="yellow"}"
# DOTNET
SPACESHIP_DOTNET_SHOW="${SPACESHIP_DOTNET_SHOW:=true}"
SPACESHIP_DOTNET_PREFIX="${SPACESHIP_DOTNET_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_DOTNET_SUFFIX="${SPACESHIP_DOTNET_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_DOTNET_SYMBOL="${SPACESHIP_DOTNET_SYMBOL:=".NET "}"
SPACESHIP_DOTNET_COLOR="${SPACESHIP_DOTNET_COLOR:="128"}"
# EMBER
SPACESHIP_EMBER_SHOW="${SPACESHIP_EMBER_SHOW:=true}"
SPACESHIP_EMBER_PREFIX="${SPACESHIP_EMBER_PREFIX:="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_EMBER_SUFFIX="${SPACESHIP_EMBER_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_EMBER_SYMBOL="${SPACESHIP_EMBER_SYMBOL:="🐹 "}"
SPACESHIP_EMBER_COLOR="${SPACESHIP_EMBER_COLOR:="210"}"
# KUBECONTEXT
SPACESHIP_KUBECONTEXT_SHOW="${SPACESHIP_KUBECONTEXT_SHOW:=true}"
SPACESHIP_KUBECONTEXT_PREFIX="${SPACESHIP_KUBECONTEXT_PREFIX:="at "}"
SPACESHIP_KUBECONTEXT_SUFFIX="${SPACESHIP_KUBECONTEXT_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_KUBECONTEXT_SYMBOL="${SPACESHIP_KUBECONTEXT_SYMBOL:="☸️ "}"
SPACESHIP_KUBECONTEXT_COLOR="${SPACESHIP_KUBECONTEXT_COLOR:="cyan"}"
# EXECUTION TIME
SPACESHIP_EXEC_TIME_SHOW="${SPACESHIP_EXEC_TIME_SHOW:=true}"
SPACESHIP_EXEC_TIME_PREFIX="${SPACESHIP_EXEC_TIME_PREFIX:="took "}"
SPACESHIP_EXEC_TIME_SUFFIX="${SPACESHIP_EXEC_TIME_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_EXEC_TIME_COLOR="${SPACESHIP_EXEC_TIME_COLOR:="yellow"}"
SPACESHIP_EXEC_TIME_ELAPSED="${SPACESHIP_EXEC_TIME_ELAPSED:=2}"
# BATTERY
SPACESHIP_BATTERY_SHOW="${SPACESHIP_BATTERY_SHOW:=true}"
SPACESHIP_BATTERY_ALWAYS_SHOW="${SPACESHIP_BATTERY_ALWAYS_SHOW:=false}"
SPACESHIP_BATTERY_PREFIX="${SPACESHIP_BATTERY_PREFFIX:=""}"
SPACESHIP_BATTERY_SUFFIX="${SPACESHIP_BATTERY_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_BATTERY_CHARGING_SYMBOL="${SPACESHIP_BATTERY_CHARGING_SYMBOL:="⇡"}"
SPACESHIP_BATTERY_DISCHARGING_SYMBOL="${SPACESHIP_BATTERY_DISCHARGING_SYMBOL:="⇣"}"
SPACESHIP_BATTERY_FULL_SYMBOL="${SPACESHIP_BATTERY_FULL_SYMBOL:="•"}"
SPACESHIP_BATTERY_THRESHOLD="${SPACESHIP_BATTERY_THRESHOLD:=10}"
# VI_MODE
SPACESHIP_VI_MODE_SHOW="${SPACESHIP_VI_MODE_SHOW:=true}"
SPACESHIP_VI_MODE_PREFIX="${SPACESHIP_VI_MODE_PREFIX:=""}"
SPACESHIP_VI_MODE_SUFFIX="${SPACESHIP_VI_MODE_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_VI_MODE_INSERT="${SPACESHIP_VI_MODE_INSERT:="[I]"}"
SPACESHIP_VI_MODE_NORMAL="${SPACESHIP_VI_MODE_NORMAL:="[N]"}"
SPACESHIP_VI_MODE_COLOR="${SPACESHIP_VI_MODE_COLOR:="white"}"
# JOBS
SPACESHIP_JOBS_SHOW="${SPACESHIP_JOBS_SHOW:=true}"
SPACESHIP_JOBS_PREFIX="${SPACESHIP_JOBS_PREFIX:=""}"
SPACESHIP_JOBS_SUFFIX="${SPACESHIP_JOBS_SUFFIX:=" "}"
SPACESHIP_JOBS_SYMBOL="${SPACESHIP_JOBS_SYMBOL:="✦"}"
SPACESHIP_JOBS_COLOR="${SPACESHIP_JOBS_COLOR:="blue"}"
# EXIT CODE
SPACESHIP_EXIT_CODE_SHOW="${SPACESHIP_EXIT_CODE_SHOW:=false}"
SPACESHIP_EXIT_CODE_PREFIX="${SPACESHIP_EXIT_CODE_PREFIX:=""}"
SPACESHIP_EXIT_CODE_SUFFIX="${SPACESHIP_EXIT_CODE_SUFFIX:=" "}"
SPACESHIP_EXIT_CODE_SYMBOL="${SPACESHIP_EXIT_CODE_SYMBOL:="✘"}"
SPACESHIP_EXIT_CODE_COLOR="${SPACESHIP_EXIT_CODE_COLOR:="red"}"
# Amazon Web Services (AWS)
SPACESHIP_AWS_SHOW="${SPACESHIP_AWS_SHOW:=true}"
SPACESHIP_AWS_PREFIX="${SPACESHIP_AWS_PREFIX:="using "}"
SPACESHIP_AWS_SUFFIX="${SPACESHIP_AWS_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_AWS_SYMBOL="${SPACESHIP_AWS_SYMBOL:="☁️ "}"
SPACESHIP_AWS_COLOR="${SPACESHIP_AWS_COLOR:="208"}"
# ------------------------------------------------------------------------------
# HELPERS
# Helpers for common used actions
# ------------------------------------------------------------------------------
# Check if command exists in $PATH
# USAGE:
# _exists <command>
_exists() {
command -v $1 > /dev/null 2>&1
}
# Check if the current directory is in a Git repository.
# USAGE:
# _is_git
_is_git() {
command git rev-parse --is-inside-work-tree &>/dev/null
}
# Check if the current directory is in a Mercurial repository.
# USAGE:
# _is_hg
_is_hg() {
local root="$(pwd -P)"
while [[ $root && ! -d $root/.hg ]]
do
root="${root%/*}"
done
[[ -n "$root" ]] &>/dev/null
}
# Draw prompt section (bold is used as default)
# USAGE:
# _prompt_section <color> [prefix] <content> [suffix]
SPACESHIP_OPENED=false # Internal variable for checking if prompt is opened
_prompt_section() {
local color prefix content suffix
[[ -n $1 ]] && color="%F{$1}" || color="%f"
[[ -n $2 ]] && prefix="$2" || prefix=""
[[ -n $3 ]] && content="$3" || content=""
[[ -n $4 ]] && suffix="$4" || suffix=""
[[ -z $3 && -z $4 ]] && content=$2 prefix=''
echo -n "%{%B%}" # set bold
if [[ $SPACESHIP_OPENED == true ]] && [[ $SPACESHIP_PROMPT_PREFIXES_SHOW == true ]]; then
echo -n "$prefix"
fi
SPACESHIP_OPENED=true
echo -n "%{%b%}" # unset bold
echo -n "%{%B$color%}" # set color
echo -n "$content" # section content
echo -n "%{%b%f%}" # unset color
echo -n "%{%B%}" # reset bold, if it was diabled before
if [[ $SPACESHIP_PROMPT_SUFFIXES_SHOW == true ]]; then
echo -n "$suffix"
fi
echo -n "%{%b%}" # unset bold
}
# Print message backward compatibility warning
# USAGE:
# _deprecate <deprecated> <actual>
_deprecated() {
[[ -n $1 && -n $2 ]] || return
local deprecated=$1 actual=$2 b=$bold_color r=$reset_color
local deprecated_value=${(P)deprecated} # the value of variable name $deprecated
[[ -n $deprecated_value ]] || return
echo "${b}\$$deprecated${r} is deprecated. Use ${b}\$$actual${r} instead."
}
# Display seconds in human readable fromat
# Based on http://stackoverflow.com/a/32164707/3859566
# USAGE:
# _displaytime <seconds>
_displaytime() {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
[[ $D > 0 ]] && printf '%dd ' $D
[[ $H > 0 ]] && printf '%dh ' $H
[[ $M > 0 ]] && printf '%dm ' $M
printf '%ds' $S
}
# ------------------------------------------------------------------------------
# HOOKS
# ZSH hooks for advanced actions
# ------------------------------------------------------------------------------
# Execution time start
spaceship_exec_time_preexec_hook() {
[[ $SPACESHIP_EXEC_TIME_SHOW == false ]] && return
SPACESHIP_EXEC_TIME_start=$(date +%s)
}
# Execution time end
spaceship_exec_time_precmd_hook() {
[[ $SPACESHIP_EXEC_TIME_SHOW == false ]] && return
[[ -n $SPACESHIP_EXEC_TIME_duration ]] && unset SPACESHIP_EXEC_TIME_duration
[[ -z $SPACESHIP_EXEC_TIME_start ]] && return
local SPACESHIP_EXEC_TIME_stop=$(date +%s)
SPACESHIP_EXEC_TIME_duration=$(( $SPACESHIP_EXEC_TIME_stop - $SPACESHIP_EXEC_TIME_start ))
unset SPACESHIP_EXEC_TIME_start
}
# ------------------------------------------------------------------------------
# SECTIONS
# The parts the prompt consists of
# ------------------------------------------------------------------------------
# TIME
spaceship_time() {
[[ $SPACESHIP_TIME_SHOW == false ]] && return
local time_str
if [[ $SPACESHIP_TIME_FORMAT != false ]]; then
time_str="${SPACESHIP_TIME_FORMAT}"
elif [[ $SPACESHIP_TIME_12HR == true ]]; then
time_str="%D{%r}"
else
time_str="%D{%T}"
fi
_prompt_section \
"$SPACESHIP_TIME_COLOR" \
"$SPACESHIP_TIME_PREFIX" \
"$time_str" \
"$SPACESHIP_TIME_SUFFIX"
}
# USER
# If user is root, then paint it in red. Otherwise, just print in yellow.
spaceship_user() {
[[ $SPACESHIP_USER_SHOW == false ]] && return
if [[ $LOGNAME != $USER ]] || [[ $UID == 0 ]] || [[ -n $SSH_CONNECTION ]]; then
local user_color
if [[ $USER == 'root' ]]; then
user_color=$SPACESHIP_USER_COLOR_ROOT
else
user_color="$SPACESHIP_USER_COLOR"
fi
_prompt_section \
"$user_color" \
"$SPACESHIP_USER_PREFIX" \
'%n' \
"$SPACESHIP_USER_SUFFIX"
fi
}
# HOST
# If there is an ssh connections, current machine name.
spaceship_host() {
[[ $SPACESHIP_HOST_SHOW == false ]] && return
[[ -n $SSH_CONNECTION ]] || return
_prompt_section \
"$SPACESHIP_HOST_COLOR" \
"$SPACESHIP_HOST_PREFIX" \
'%m' \
"$SPACESHIP_HOST_SUFFIX"
}
# DIR
# Current directory. Return only three last items of path
spaceship_dir() {
[[ $SPACESHIP_DIR_SHOW == false ]] && return
_prompt_section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
"%${SPACESHIP_DIR_TRUNC}~" \
"$SPACESHIP_DIR_SUFFIX"
}
# GIT BRANCH
# Show current git brunch using git_current_status from Oh-My-Zsh
spaceship_git_branch() {
[[ $SPACESHIP_GIT_BRANCH_SHOW == false ]] && return
_is_git || return
_prompt_section \
"$SPACESHIP_GIT_BRANCH_COLOR" \
"$SPACESHIP_GIT_BRANCH_PREFIX$(git_current_branch)$SPACESHIP_GIT_BRANCH_SUFFIX"
}
# GIT STATUS
# Check if current dir is a git repo, set up ZSH_THEME_* variables
# and show git status using git_prompt_status from Oh-My-Zsh
# Reference:
# https://github.com/robbyrussell/oh-my-zsh/blob/master/lib/git.zsh
spaceship_git_status() {
[[ $SPACESHIP_GIT_STATUS_SHOW == false ]] && return
_is_git || return
ZSH_THEME_GIT_PROMPT_UNTRACKED=$SPACESHIP_GIT_STATUS_UNTRACKED
ZSH_THEME_GIT_PROMPT_ADDED=$SPACESHIP_GIT_STATUS_ADDED
ZSH_THEME_GIT_PROMPT_MODIFIED=$SPACESHIP_GIT_STATUS_MODIFIED
ZSH_THEME_GIT_PROMPT_RENAMED=$SPACESHIP_GIT_STATUS_RENAMED
ZSH_THEME_GIT_PROMPT_DELETED=$SPACESHIP_GIT_STATUS_DELETED
ZSH_THEME_GIT_PROMPT_STASHED=$SPACESHIP_GIT_STATUS_STASHED
ZSH_THEME_GIT_PROMPT_UNMERGED=$SPACESHIP_GIT_STATUS_UNMERGED
ZSH_THEME_GIT_PROMPT_AHEAD=$SPACESHIP_GIT_STATUS_AHEAD
ZSH_THEME_GIT_PROMPT_BEHIND=$SPACESHIP_GIT_STATUS_BEHIND
ZSH_THEME_GIT_PROMPT_DIVERGED=$SPACESHIP_GIT_STATUS_DIVERGED
local git_status="$(git_prompt_status)"
if [[ -n $git_status ]]; then
# Status prefixes are colorized
_prompt_section \
"$SPACESHIP_GIT_STATUS_COLOR" \
"$SPACESHIP_GIT_STATUS_PREFIX$git_status$SPACESHIP_GIT_STATUS_SUFFIX"
fi
}
# GIT
# Show both git branch and git status:
# spaceship_git_branch
# spaceship_git_status
spaceship_git() {
[[ $SPACESHIP_GIT_SHOW == false ]] && return
local git_branch="$(spaceship_git_branch)" git_status="$(spaceship_git_status)"
[[ -z $git_branch ]] && return
_prompt_section \
'white' \
"$SPACESHIP_GIT_PREFIX" \
"${git_branch}${git_status}" \
"$SPACESHIP_GIT_SUFFIX"
}
# MERCURIAL BRANCH
# Show current hg branch
spaceship_hg_branch() {
[[ $SPACESHIP_HG_BRANCH_SHOW == false ]] && return
_is_hg || return
_prompt_section \
"$SPACESHIP_HG_BRANCH_COLOR" \
"$SPACESHIP_HG_BRANCH_PREFIX"$(hg branch)"$SPACESHIP_HG_BRANCH_SUFFIX"
}
# MERCURIAL STATUS
# Check if current dir is a hg repo and show hg status as indicators
spaceship_hg_status() {
[[ $SPACESHIP_HG_STATUS_SHOW == false ]] && return
_is_hg || return
local INDEX=$(hg status 2>/dev/null) hg_status=""
# Indicators are suffixed instead of prefixed to each other to
# provide uniform view across git and mercurial indicators
if $(echo "$INDEX" | grep -E '^\? ' &> /dev/null); then
hg_status="$SPACESHIP_HG_STATUS_UNTRACKED$hg_status"
elif $(echo "$INDEX" | grep -E '^A ' &> /dev/null); then
hg_status="$SPACESHIP_HG_STATUS_ADDED$hg_status"
elif $(echo "$INDEX" | grep -E '^M ' &> /dev/null); then
hg_status="$SPACESHIP_HG_STATUS_MODIFIED$hg_status"
elif $(echo "$INDEX" | grep -E '^(R|!)' &> /dev/null); then
hg_status="$SPACESHIP_HG_STATUS_DELETED$hg_status"
fi
if [[ -n $hg_status ]]; then
_prompt_section \
"$SPACESHIP_HG_STATUS_COLOR" \
"$SPACESHIP_HG_STATUS_PREFIX"$hg_status"$SPACESHIP_HG_STATUS_SUFFIX"
fi
}
# MERCURIAL
# Show both hg branch and hg status:
# spaceship_hg_branch
# spaceship_hg_status
spaceship_hg() {
[[ $SPACESHIP_HG_SHOW == false ]] && return
local hg_branch="$(spaceship_hg_branch)" hg_status="$(spaceship_hg_status)"
[[ -z $hg_branch ]] && return
_prompt_section \
'white' \
"$SPACESHIP_HG_PREFIX" \
"${hg_branch}${hg_status}" \
"$SPACESHIP_HG_SUFFIX"
}
# PACKAGE
# Show current package version
spaceship_package() {
[[ $SPACESHIP_PACKAGE_SHOW == false ]] && return
# Show package version only when repository is a package
# @todo: add more package managers
[[ -f package.json ]] || return
_exists npm || return
# Grep and cut out package version
# Grep -E does not support \d for digits shortcut, should use [:digit:] or [0-9] instead
local package_version=$(grep -E '"version": "v?([0-9]+\.){1,}' package.json | cut -d\" -f4 2> /dev/null)
# Handle version not found
if [ ! "$package_version" ]; then
package_version=" ⚠"
else
package_version=" v${package_version}"
fi
_prompt_section \
"$SPACESHIP_PACKAGE_COLOR" \
"$SPACESHIP_PACKAGE_PREFIX" \
"${SPACESHIP_PACKAGE_SYMBOL}${package_version}" \
"$SPACESHIP_PACKAGE_SUFFIX"
}
# NODE
# Show current version of node, exception system.
spaceship_node() {
[[ $SPACESHIP_NODE_SHOW == false ]] && return
# Show NODE status only for JS-specific folders
[[ -f package.json || -d node_modules || -n *.js(#qN^/) ]] || return
local node_version
if _exists nvm; then
node_version=$(nvm current 2>/dev/null)
[[ $node_version == "system" || $node_version == "node" ]] && return
elif _exists nodenv; then
node_version=$(nodenv version-name)
[[ $node_version == "system" || $node_version == "node" ]] && return
elif _exists node; then
node_version=$(node -v 2>/dev/null)
[[ $node_version == $SPACESHIP_NODE_DEFAULT_VERSION ]] && return
else
return
fi
_prompt_section \
"$SPACESHIP_NODE_COLOR" \
"$SPACESHIP_NODE_PREFIX" \
"${SPACESHIP_NODE_SYMBOL}${node_version}" \
"$SPACESHIP_NODE_SUFFIX"
}
# RUBY
# Show current version of Ruby
spaceship_ruby() {
[[ $SPACESHIP_RUBY_SHOW == false ]] && return
# Show versions only for Ruby-specific folders
[[ -f Gemfile || -f Rakefile || -n *.rb(#qN^/) ]] || return
local ruby_version
if _exists rvm-prompt; then
ruby_version=$(rvm-prompt i v g)
elif _exists chruby; then
ruby_version=$(chruby | sed -n -e 's/ \* //p')
elif _exists rbenv; then
ruby_version=$(rbenv version-name)
else
return
fi
[[ "${ruby_version}" == "system" ]] && return
# Add 'v' before ruby version that starts with a number
[[ "${ruby_version}" =~ ^[0-9].+$ ]] && ruby_version="v${ruby_version}"
_prompt_section \
"$SPACESHIP_RUBY_COLOR" \
"$SPACESHIP_RUBY_PREFIX" \
"${SPACESHIP_RUBY_SYMBOL}${ruby_version}" \
"$SPACESHIP_RUBY_SUFFIX"
}
# ELIXIR
# Show current version of Elixir
spaceship_elixir() {
[[ $SPACESHIP_ELIXIR_SHOW == false ]] && return
# Show versions only for Elixir-specific folders
[[ -f mix.exs || -n *.ex(#qN^/) || -n *.exs(#qN^/) ]] || return
local elixir_version
if _exists kiex; then
elixir_version="${ELIXIR_VERSION}"
elif _exists exenv; then
elixir_version=$(exenv version-name)
fi
if [[ $elixir_version == "" ]]; then
_exists elixir || return
elixir_version=$(elixir -v 2>/dev/null | grep "Elixir" --color=never | cut -d ' ' -f 2)
fi
[[ $elixir_version == "system" ]] && return
[[ $elixir_version == $SPACESHIP_ELIXIR_DEFAULT_VERSION ]] && return
# Add 'v' before elixir version that starts with a number
[[ "${elixir_version}" =~ ^[0-9].+$ ]] && elixir_version="v${elixir_version}"
_prompt_section \
"$SPACESHIP_ELIXIR_COLOR" \
"$SPACESHIP_ELIXIR_PREFIX" \
"${SPACESHIP_ELIXIR_SYMBOL}${elixir_version}" \
"$SPACESHIP_ELIXIR_SUFFIX"
}
# XCODE
# Show current version of Xcode
spaceship_xcode() {
_exists xcenv || return
local xcode_path
if [[ $SPACESHIP_SWIFT_SHOW_GLOBAL == true ]] ; then
xcode_path=$(xcenv version | sed 's/ .*//')
elif [[ $SPACESHIP_SWIFT_SHOW_LOCAL == true ]] ; then
if xcenv version | grep ".xcode-version" > /dev/null; then
xcode_path=$(xcenv version | sed 's/ .*//')
fi
fi
if [ -n "${xcode_path}" ]; then
local xcode_version_path=$xcode_path"/Contents/version.plist"
if [ -f ${xcode_version_path} ]; then
if _exists defaults; then
local xcode_version=$(defaults read ${xcode_version_path} CFBundleShortVersionString)
_prompt_section \
"$SPACESHIP_XCODE_COLOR" \
"$SPACESHIP_XCODE_PREFIX" \
"${SPACESHIP_XCODE_SYMBOL}${xcode_version}" \
"$SPACESHIP_XCODE_SUFFIX"
fi
fi
fi
}
# SWIFT
# Show current version of Swift
spaceship_swift() {
_exists swiftenv || return
local swift_version
if [[ $SPACESHIP_SWIFT_SHOW_GLOBAL == true ]] ; then
swift_version=$(swiftenv version | sed 's/ .*//')
elif [[ $SPACESHIP_SWIFT_SHOW_LOCAL == true ]] ; then
if swiftenv version | grep ".swift-version" > /dev/null; then
swift_version=$(swiftenv version | sed 's/ .*//')
fi
fi
[ -n "${swift_version}" ] || return
_prompt_section \
"$SPACESHIP_SWIFT_COLOR" \
"$SPACESHIP_SWIFT_PREFIX" \
"${SPACESHIP_SWIFT_SYMBOL}${swift_version}" \
"$SPACESHIP_SWIFT_SUFFIX"
}
# GOLANG
# Show current version of Go
spaceship_golang() {
[[ $SPACESHIP_GOLANG_SHOW == false ]] && return
# If there are Go-specific files in current directory, or current directory is under the GOPATH
[[ -d Godeps || -f glide.yaml || -n *.go(#qN^/) || -f Gopkg.yml || -f Gopkg.lock || ( $GOPATH && $PWD =~ $GOPATH ) ]] || return
_exists go || return
local go_version=$(go version | grep --colour=never -oE '[[:digit:]].[[:digit:]]')
_prompt_section \
"$SPACESHIP_GOLANG_COLOR" \
"$SPACESHIP_GOLANG_PREFIX" \
"${SPACESHIP_GOLANG_SYMBOL}v${go_version}" \
"$SPACESHIP_GOLANG_SUFFIX"
}
# PHP
# Show current version of PHP
spaceship_php() {
[[ $SPACESHIP_PHP_SHOW == false ]] && return
# Show only if php files exist in current directory
[[ -n *.php(#qN^/) ]] || return
_exists php || return
local php_version=$(php -v 2>&1 | grep --color=never -oe "^PHP\s*[0-9.]*" | awk '{print $2}')
_prompt_section \
"$SPACESHIP_PHP_COLOR" \
"$SPACESHIP_PHP_PREFIX" \
"${SPACESHIP_PHP_SYMBOL}v${php_version}" \
"${SPACESHIP_PHP_SUFFIX}"
}
# RUST
# Show current version of Rust
spaceship_rust() {
[[ $SPACESHIP_RUST_SHOW == false ]] && return
# If there are Rust-specific files in current directory
[[ -f Cargo.toml || -n *.rs(#qN^/) ]] || return
_exists rustc || return
local rust_version=$(rustc --version | grep --colour=never -oE '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]')
_prompt_section \
"$SPACESHIP_RUST_COLOR" \
"$SPACESHIP_RUST_PREFIX" \
"${SPACESHIP_RUST_SYMBOL}v${rust_version}" \
"$SPACESHIP_RUST_SUFFIX"
}
# HASKELL
# Show current version of Haskell Tool Stack.
spaceship_haskell() {
[[ $SPACESHIP_HASKELL_SHOW == false ]] && return
# If there are stack files in current directory
[[ -f stack.yaml ]] || return
# The command is stack, so do not change this to haskell.
_exists stack || return
local haskell_version=$(stack --numeric-version)
_prompt_section \
"$SPACESHIP_HASKELL_COLOR" \
"$SPACESHIP_HASKELL_PREFIX" \
"${SPACESHIP_HASKELL_SYMBOL}v${haskell_version}" \
"$SPACESHIP_HASKELL_SUFFIX"
}
# JULIA
# Show current version of Julia
spaceship_julia() {
[[ $SPACESHIP_JULIA_SHOW == false ]] && return
# If there are julia files in current directory
[[ -n *.jl(#qN^/) ]] || return
_exists julia || return
local julia_version=$(julia --version | grep --colour=never -oE '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]')
_prompt_section \
"$SPACESHIP_JULIA_COLOR" \
"$SPACESHIP_JULIA_PREFIX" \
"${SPACESHIP_JULIA_SYMBOL}v${julia_version}" \
"$SPACESHIP_JULIA_SUFFIX"
}
# DOCKER
# Show current Docker version and connected machine
spaceship_docker() {
[[ $SPACESHIP_DOCKER_SHOW == false ]] && return
_exists docker || return
# Show Docker status only for Docker-specific folders
[[ -f Dockerfile || -f docker-compose.yml ]] || return
# if docker daemon isn't running you'll get an error saying it can't connect
docker info 2>&1 | grep -q "Cannot connect" && return
local docker_version=$(docker version -f "{{.Server.Version}}")
if [[ -n $DOCKER_MACHINE_NAME ]]; then
docker_version+=" via ($DOCKER_MACHINE_NAME)"
fi
_prompt_section \
"$SPACESHIP_DOCKER_COLOR" \
"$SPACESHIP_DOCKER_PREFIX" \
"${SPACESHIP_DOCKER_SYMBOL}v${docker_version}" \
"$SPACESHIP_DOCKER_SUFFIX"
}
# Amazon Web Services (AWS)
# Shows selected AWS cli profile.
spaceship_aws() {
[[ $SPACESHIP_AWS_SHOW == false ]] && return
# Check if the AWS-cli is installed
_exists aws || return
# Is the current profile not the default profile
[[ -z $AWS_DEFAULT_PROFILE ]] || [[ "$AWS_DEFAULT_PROFILE" == "default" ]] && return
# Show prompt section
_prompt_section \
"$SPACESHIP_AWS_COLOR" \
"$SPACESHIP_AWS_PREFIX" \
"${SPACESHIP_AWS_SYMBOL}$AWS_DEFAULT_PROFILE" \
"$SPACESHIP_AWS_SUFFIX"
}
# VENV
# Show current virtual environment (Python).
spaceship_venv() {
[[ $SPACESHIP_VENV_SHOW == false ]] && return
# Check if the current directory running via Virtualenv
[ -n "$VIRTUAL_ENV" ] && _exists deactivate || return
_prompt_section \
"$SPACESHIP_VENV_COLOR" \
"$SPACESHIP_VENV_PREFIX" \
"$VIRTUAL_ENV:t" \
"$SPACESHIP_VENV_SUFFIX"
}
# CONDA
# Show current conda virtual environment
spaceship_conda() {
[[ $SPACESHIP_CONDA_SHOW == false ]] && return
# Check if running via conda virtualenv
_exists conda && [ -n "$CONDA_DEFAULT_ENV" ] || return
_prompt_section \
"$SPACESHIP_CONDA_COLOR" \
"$SPACESHIP_CONDA_PREFIX" \
"${SPACESHIP_CONDA_SYMBOL}${CONDA_DEFAULT_ENV}" \
"$SPACESHIP_CONDA_SUFFIX"
}
# PYENV
# Show current version of pyenv python, including system.
spaceship_pyenv() {
[[ $SPACESHIP_PYENV_SHOW == false ]] && return
# Show pyenv python version only for Python-specific folders
[[ -f requirements.txt ]] || [[ -n *.py(#qN^/) ]] || return
_exists pyenv || return # Do nothing if pyenv is not installed
local pyenv_status=${$(pyenv version-name 2>/dev/null)//:/ }
_prompt_section \
"$SPACESHIP_PYENV_COLOR" \
"$SPACESHIP_PYENV_PREFIX" \
"${SPACESHIP_PYENV_SYMBOL}${pyenv_status}" \
"$SPACESHIP_PYENV_SUFFIX"
}
# DOTNET
# Show current version of .NET SDK
spaceship_dotnet() {
[[ $SPACESHIP_DOTNET_SHOW == false ]] && return
# Show DOTNET status only for folders containing project.json, global.json, .csproj, .xproj or .sln files
[[ -f project.json || -f global.json || -n *.csproj(#qN^/) || -n *.xproj(#qN^/) || -n *.sln(#qN^/) ]] || return
_exists dotnet || return
# dotnet-cli automatically handles SDK pinning (specified in a global.json file)
# therefore, this already returns the expected version for the current directory
local dotnet_version=$(dotnet --version 2>/dev/null)
_prompt_section \