From 773f1010b9822f3837fb6910af09518c1f2fa838 Mon Sep 17 00:00:00 2001
From: jeremiejig <me@jeremiejig.fr>
Date: Thu, 17 Sep 2015 22:41:56 +0200
Subject: [PATCH] omf.destroy: find the most recent backup of config.  using
 XDG_CONFIG_HOME

---
 pkg/omf/cli/omf.destroy.fish | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/pkg/omf/cli/omf.destroy.fish b/pkg/omf/cli/omf.destroy.fish
index 0a802cd..5e56f8a 100644
--- a/pkg/omf/cli/omf.destroy.fish
+++ b/pkg/omf/cli/omf.destroy.fish
@@ -5,8 +5,15 @@ function omf.destroy -d "Remove Oh My Fish"
     omf.remove_package $pkg >/dev/null ^&1
   end
 
-  if test -e "$HOME/.config/fish/config.copy"
-    mv "$HOME/.config/fish/config".{copy,fish}
+  set -l fish_config $XDG_CONFIG_HOME/fish
+  if test "$fish_config" = "/fish"
+    set fish_config $HOME/.config/fish
+  end
+
+  set -l localbackup (find $fish_config -regextype posix-extended -regex '^.*fish/config\.[[:digit:]]+\.copy$' |\
+    sort -r |head -1)
+  if test -n $localbackup
+    mv $localbackup "$fish_config/config.fish"
   end
 
   if test "$OMF_PATH" != "$HOME"
-- 
GitLab