about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-07-03 12:12:22 +0530
committerAndinus <andinus@nand.sh>2020-07-03 12:12:22 +0530
commit71ce3ea69a2b915162402a9dc172191031533b4a (patch)
tree509b5e48b970edd6007f9207ba4ffd576b52097e
parentbe8c40f45115720ac702843906213d16940939c1 (diff)
downloadleo-71ce3ea69a2b915162402a9dc172191031533b4a.tar.gz
Add syncemacs function
-rwxr-xr-xleo.pl35
1 files changed, 35 insertions, 0 deletions
diff --git a/leo.pl b/leo.pl
new file mode 100755
index 0000000..462d2bf
--- /dev/null
+++ b/leo.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature 'say';
+
+use lib::relative 'lib';
+use Emacs;
+
+use FindBin;
+use Path::Tiny;
+use IPC::Run3;
+use Getopt::Long qw/ GetOptions /;
+use Term::ANSIColor qw/ :pushpop colored color /;
+
+local $SIG{__WARN__} = sub { print colored( $_[0], 'yellow' ); };
+
+my %options = ();
+GetOptions(
+    \%options,
+    qw{ verbose debug }
+) or die "Error in command line arguments\n";
+
+my %dispatch = (
+    "sync emacs" => sub { Emacs::sync(\%options) },
+);
+
+if ( $dispatch{ "@ARGV" } ) {
+    $dispatch{ "@ARGV" }->();
+} else {
+    my $file = path($FindBin::RealBin . "/share/theo");
+    my @insults = split/\n%\n/, $file->slurp;
+    print LOCALCOLOR RED "[ERR] " if $options{verbose};
+    say LOCALCOLOR YELLOW $insults[ rand @insults ];
+}