Changeset 121 in bookmarks for trunk/bin/bkmk
- Timestamp:
- 02/25/16 17:53:20 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/bkmk
r120 r121 69 69 }, 70 70 71 #TODO: interactive editing of a bookmark 71 # interactive editing of a bookmark 72 edit => sub { 73 my ($identifier) = @_; 74 my $bookmark = find_bookmark($identifier) or die "Not found\n"; 75 my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi'; 76 77 # create a temp file and open it in the user's preferred editor 78 use File::Temp qw{tempfile}; 79 my ($fh, $filename) = tempfile(UNLINK => 1); 80 YAML::DumpFile($filename, $bookmark->to_hashref); 81 system($editor, $filename); 82 83 # abort on empty file 84 die "Edit canceled\n" unless -s $filename; 85 86 # update and save the bookmark 87 $bookmark = Bookmark->new(YAML::LoadFile($filename)); 88 $bookmarks->update($bookmark); 89 print Dump($bookmark->to_hashref); 90 }, 72 91 73 92 # bulk loading
Note: See TracChangeset
for help on using the changeset viewer.