Skip to content

Instantly share code, notes, and snippets.

@bayashi
Created May 2, 2019 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayashi/a8ab164cd82535a004f2ab3d3ffa98b1 to your computer and use it in GitHub Desktop.
Save bayashi/a8ab164cd82535a004f2ab3d3ffa98b1 to your computer and use it in GitHub Desktop.
Invoke this from .bashrc for daily log
#!/usr/bin/env perl
use strict;
use warnings;
my $SUBLIME = '/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl';
my $BASE_PATH = '/path/to/physical_file';
my $SHORTCUT = '/path/to/Desktop/mylog.md';
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
my $file = sprintf("%s/%s/%s%02d%02d.md", $BASE_PATH, $year, $year, ++$mon, $mday);
exit if -f $file;
open my $fh, '>', $file or die "Could not open $file $!";
print $fh <<'_TXT_';
# T
## S
* h
* f
_TXT_
close $fh;
unlink $SHORTCUT if -f $SHORTCUT;
symlink $file, $SHORTCUT;
`$SUBLIME $SHORTCUT`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment