Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf.d/pure.fish
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ _pure_set_default pure_color_jobs pure_color_normal

# Show system time
_pure_set_default pure_show_system_time false
_pure_set_default pure_system_time_format '+%T' # 12 hour time: '+%I:%M:%S %p'
_pure_set_default pure_color_system_time pure_color_mute

# Nix build environment
Expand Down
1 change: 1 addition & 0 deletions docs/components/features-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
| Option | Default | Description |
| :----------------------------------------- | :------ | :------------------------------------------------------------------ |
| **`pure_show_system_time`** | `false` | `true`: shows system time before the prompt symbol (as `%H:%M:%S`). |
| **`pure_system_time_format`** | `+%T` | `true`: shows system time in 12-hour time instead of 24-hour time. |

=== "Show system time (enabled)"

Expand Down
2 changes: 1 addition & 1 deletion functions/_pure_prompt_system_time.fish
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function _pure_prompt_system_time --description "Display system time"
if set --query pure_show_system_time; and test "$pure_show_system_time" = true
set --local time_color (_pure_set_color $pure_color_system_time)
echo "$time_color"(date '+%T')
echo "$time_color"(date $pure_system_time_format)
end
end
24 changes: 24 additions & 0 deletions tests/_pure_prompt_system_time.test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,27 @@ before_all

_pure_prompt_system_time
) = '10:01:29'

@test "_pure_prompt_system_time: displays 12hr system time when pure_system_time_format set to 12hr" (
set --universal pure_show_system_time true
set --universal pure_system_time_format '+%I:%M:%S %p'
function date
test (uname) = Darwin;
and command date -j -f "%H:%M:%S" '22:01:29' '+%I:%M:%S %p'; # MacOS
or command date -d '22:01:29' '+%I:%M:%S %p'; # Linux
end

_pure_prompt_system_time
) = '10:01:29 PM'

@test "_pure_prompt_system_time: displays 24hr system time when pure_system_time_format set to default" (
set --universal pure_show_system_time true
set --universal pure_system_time_format '+%T'
function date
test (uname) = Darwin;
and command date -j -f "%H:%M:%S" '22:01:29' '+%T'; # MacOS
or command date -d '22:01:29' '+%T'; # Linux
end

_pure_prompt_system_time
) = '22:01:29'
Loading