about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-08-27 16:19:04 +0530
committerAndinus <andinus@nand.sh>2020-08-27 16:19:04 +0530
commiteda386d91631ca79582b240f3be8fbe85beb4ec9 (patch)
tree264587d73d26e3ce5bafd040dfd4795233159d14
parent78778ce31d566fd19c52f54c6ddea2f8b4ade160 (diff)
downloadleo-eda386d91631ca79582b240f3be8fbe85beb4ec9.tar.gz
Remove aliases, move to a different function
Problem with aliases was that profile name would still be say `.ssh'
for ssh which means the archive created will be `.ssh-...tar' which is
not what I wanted.
-rwxr-xr-xleo.pl26
1 files changed, 20 insertions, 6 deletions
diff --git a/leo.pl b/leo.pl
index 3d4e6b3..7468e54 100755
--- a/leo.pl
+++ b/leo.pl
@@ -34,20 +34,34 @@ my %dispatch = (
     },
 );
 
+# These are the directories to be added to dispatch table but have
+# path names different from their profile names.
+my %directories = (
+    ssh => "$ENV{HOME}/.ssh",
+    pass => "$ENV{HOME}/.password-store",
+    mozilla => "$ENV{HOME}/.mozilla",
+    config => "$ENV{HOME}/.config",
+    emacs => "$ENV{HOME}/.emacs.d",
+    elfeed => "$ENV{HOME}/.elfeed",
+);
+
+foreach my $dir (sort keys %directories) {
+    $dispatch{$dir} = sub {
+        archive("$archive_dir/${dir}_${ymd}.tar",
+                "-C", "$directories{$dir}", ".");
+    };
+}
+
 # This adds the directories that have same path relative to $ENV{HOME}
 # as profile name.
-foreach my $profile (qw( emails music projects documents .ssh
-                         .password-store)) {
+foreach my $profile (qw( emails music projects documents videos pictures
+                         downloads )) {
     $dispatch{$profile} = sub {
         archive("$archive_dir/${profile}_$ymd.tar",
                 "-C", "$ENV{HOME}/$profile", ".");
     };
 }
 
-# Aliases for inconvenient paths.
-$dispatch{ssh} = $dispatch{".ssh"};
-$dispatch{pass} = $dispatch{".password-store"};
-
 # User must pass $tar_file first & `-C' optionally.
 sub archive {
     my $tar_file = shift @_;