From 87876280e020fc228743f8d28d6fc5c8e87339da Mon Sep 17 00:00:00 2001 From: Pieter Loubser Date: Wed, 9 Oct 2024 10:55:45 +0100 Subject: [PATCH] (maint) Make context checkFile fn expand tildes --- cli/context_command.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cli/context_command.go b/cli/context_command.go index b424e82b..a0d1645c 100644 --- a/cli/context_command.go +++ b/cli/context_command.go @@ -19,6 +19,7 @@ import ( "fmt" "os" "os/exec" + "os/user" "sort" "strings" "text/template" @@ -454,6 +455,14 @@ func (c *ctxCommand) showCommand(_ *fisk.ParseContext) error { if strings.HasPrefix(file, "op://") { return color.CyanString("1Password") } + if file[0] == '~' { + usr, err := user.Current() + if err != nil { + return color.RedString("ERROR") + } + file = strings.Replace(file, "~", usr.HomeDir, 1) + } + ok, err := fileAccessible(file) if !ok || err != nil { c.validateErrors++