-
Notifications
You must be signed in to change notification settings - Fork 6
/
prompt.yaml
92 lines (73 loc) · 2.16 KB
/
prompt.yaml
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
name: "Prompt"
cases:
- name: "Simple prompts"
stdin: |
prompt='$ '
echo "Prompt: '${prompt@P}'"
prompt='a\r\n> '
echo "Prompt: '${prompt@P}'"
prompt='\\'
echo "Prompt: '${prompt@P}'"
prompt='\81'
echo "Prompt: '${prompt@P}'"
- name: "Working dir based prompts"
stdin: |
cd /usr
prompt='\w '
echo "Prompt: '${prompt@P}'"
prompt='\W '
echo "Prompt: '${prompt@P}'"
arr=("\w" "\w")
echo "Prompt: '${arr@P}'"
echo "Prompt: '${arr[@]@P}'"
echo "Prompt: '${arr[*]@P}'"
- name: "Non-printing chars"
stdin: |
prompt='\[\]Prompt>\[\]'
echo "Prompt: '${prompt@P}'"
- name: "Hostname in prompts"
stdin: |
prompt='\h '
echo "Prompt: '${prompt@P}'"
prompt='\H '
echo "Prompt: '${prompt@P}'"
- name: "Shell name"
stdin: |
prompt='\s'
[[ "${prompt@P}" == "$(basename $0)" ]]
- name: "Shell version info"
stdin: |
prompt='\v'
[[ "${prompt@P}" =~ ^\d+\.\d+$ ]] && echo "Version is well-formatted"
prompt='\V'
[[ "${prompt@P}" == ^\d+\.\d+\.\d+$ ]] && echo "Release is correct"
- name: "Simple date"
stdin: |
prompt='\d'
[[ "${prompt@P}" == $(date +'%a %b %d') ]] && echo '\d date matches'
- name: "Date format with plain string"
stdin: |
prompt='\D{something}'
echo "Date format with plain string: '${prompt@P}'"
- name: "Date format with year"
stdin: |
prompt='\d{%Y}'
echo "Date format with year: '${prompt@P}'"
- name: "Time format: @"
stdin: |
prompt='\@'
expanded=${prompt@P}
roundtripped=$(date --date="${expanded}" +'%I:%M %p')
[[ ${expanded} == ${roundtripped} ]] && echo "Time matches"
- name: "Time format: T"
stdin: |
prompt='\T'
expanded=${prompt@P}
roundtripped=$(date --date="${expanded}" +'%I:%M:%S')
[[ ${expanded} == ${roundtripped} ]] && echo "Time matches"
- name: "Time format: t"
stdin: |
prompt='\t'
expanded=${prompt@P}
roundtripped=$(date --date="${expanded}" +'%H:%M:%S')
[[ ${expanded} == ${roundtripped} ]] && echo "Time matches"