From eda386d91631ca79582b240f3be8fbe85beb4ec9 Mon Sep 17 00:00:00 2001 From: Andinus Date: Thu, 27 Aug 2020 16:19:04 +0530 Subject: 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. --- leo.pl | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'leo.pl') 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 @_; -- cgit 1.4.1-2-gfad0