From ac58eab3f8e997a2ba88dc528811aace7e85bdb2 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 7 Dec 2018 20:22:11 +0100 Subject: [PATCH 1/2] Replace "^" redirection with "2>" The former is deprecated in fish 3.0, and can even optionally be turned off. --- conf.d/pure.fish | 6 +++--- functions/__parse_git_branch.fish | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf.d/pure.fish b/conf.d/pure.fish index fd889a15..2c88bccc 100644 --- a/conf.d/pure.fish +++ b/conf.d/pure.fish @@ -89,20 +89,20 @@ function pre_prompt --on-event fish_prompt end # Check if is on a Git repository - set -l is_git_repository (command git rev-parse --is-inside-work-tree ^/dev/null) + set -l is_git_repository (command git rev-parse --is-inside-work-tree 2>/dev/null) if test -n "$is_git_repository" set git_branch_name (__parse_git_branch) # Check if there are files to commit - set -l is_git_dirty (command git status --porcelain --ignore-submodules ^/dev/null) + set -l is_git_dirty (command git status --porcelain --ignore-submodules 2>/dev/null) if test -n "$is_git_dirty" set git_dirty $pure_symbol_git_dirty end # Check if there is an upstream configured - command git rev-parse --abbrev-ref '@{upstream}' >/dev/null ^&1; and set -l has_upstream + command git rev-parse --abbrev-ref '@{upstream}' >/dev/null 2>&1; and set -l has_upstream if set -q has_upstream command git rev-list --left-right --count 'HEAD...@{upstream}' | read -la git_status diff --git a/functions/__parse_git_branch.fish b/functions/__parse_git_branch.fish index a0d75325..dba19546 100644 --- a/functions/__parse_git_branch.fish +++ b/functions/__parse_git_branch.fish @@ -1,4 +1,4 @@ function __parse_git_branch -d "Parse current Git branch name" - command git symbolic-ref --short HEAD ^/dev/null; + command git symbolic-ref --short HEAD 2>/dev/null; or echo (command git show-ref --head -s --abbrev HEAD)[1] end From 1f363cd7b584c4c35a1e8ca3ca9affb93cdc29d3 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 7 Dec 2018 20:29:53 +0100 Subject: [PATCH 2/2] __format_time: Force math scale to 0 Fish 3's new math builtin defaults to float output (with trailing 0s removed), and modulo on things with a non-integer component retains that component, i.e. math 3 % 2 # is 1 math 3.5 % 2 # is 1.5 - the ".5" is just not touched This requires fish 2.4.0, I'm not sure if anything else in pure does. Alternatively, one could `string replace -r '\..*' ''` on every math call here. --- functions/__format_time.fish | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/__format_time.fish b/functions/__format_time.fish index 1831dbfb..e0097195 100644 --- a/functions/__format_time.fish +++ b/functions/__format_time.fish @@ -1,9 +1,9 @@ function __format_time -d "Format milliseconds to a human readable format" set -l milliseconds $argv[1] - set -l seconds (math "$milliseconds / 1000 % 60") - set -l minutes (math "$milliseconds / 60000 % 60") - set -l hours (math "$milliseconds / 3600000 % 24") - set -l days (math "$milliseconds / 86400000") + set -l seconds (math -s0 "$milliseconds / 1000 % 60") + set -l minutes (math -s0 "$milliseconds / 60000 % 60") + set -l hours (math -s0 "$milliseconds / 3600000 % 24") + set -l days (math -s0 "$milliseconds / 86400000") set -l time set -l threshold $argv[2]