dotfiles

My personal dotfiles

commit 1c106a15c43ec2247c71d42a65bfb0daa6d03435
parent c3d9470e4daf30be63d5d4d43d81653b6ab995a1
Author: Pablo Emilio Escobar Gaviria <pablo-escobar@riseup.net>
Date:   Fri, 29 Jan 2021 11:50:02 -0300

Added two new options to the config manager

Diffstat:
M.config/fish/functions/config.fish | 25++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/.config/fish/functions/config.fish b/.config/fish/functions/config.fish
@@ -1,10 +1,10 @@
-function config
+function config -d "A simple configuration manager"
   # Calls git in the appropriate repository
   function _call_git
     git --git-dir="$HOME/Documents/dotfiles" --work-tree="$HOME" $argv
   end
 
-  argparse u/update= a-add=+ r-rm=+ l/list g-log -- $argv
+  argparse u/update= a-add=+ r-rm=+ l/list g-log s/status d/diff -- $argv
 
   # List the dotfiles specified in configurations list
   if test -n "$_flag_list"
@@ -12,11 +12,30 @@ function config
     return
   end
 
+  # Call git log
   if test -n "$_flag_log"
     _call_git log
     return
   end
 
+  # Show the configuration files that have been modified
+  if test -n "$_flag_status"
+    echo 'modified files:'
+    _call_git status \
+      | grep 'modified' \
+      | awk '{ print $2 }' \
+      | xargs -r realpath \
+      | string replace "$HOME" '~' \
+      | xargs -r -n 1 printf '    %s\n'
+    return
+  end
+
+  # Call git diff
+  if test -n "$_flag_diff"
+    _call_git diff
+    return
+  end
+
   # Add files to the list of dotfiles
   for item in $_flag_add
     echo "Adding '$item' to the list of dotfiles"
@@ -27,10 +46,10 @@ function config
   for item in $_flag_rm
     echo "Removing '$item' from the list of dotfile"
 
+    # Set is used because 'item' may be a directory
     set pattern (realpath "$item")
     set pattern (string replace --all '/' '\/' "$pattern")
     set pattern (string replace --all '.' '\.' "$pattern")
-
     sed -e "/^$pattern/d" -i ~/.local/share/configs.list
   end