パルカワ2

最近はFlutterをやっています

ファイルを削除する前に中身を確認することが多いので、中身を出力してから削除の確認をするヤツ作った。

test.rbとかtest.plとか適当に作りまくるので、それの削除とかに使う。

#!perl

use 5.16.1;
use strict;
use warnings;
use Path::Tiny;
use IO::Prompt::Simple;

main(@ARGV);

sub main {
    my (@files) = @_;
    for my $file (@files) {
        next if !confirm($file);
        del($file);
    }
}

sub confirm {
    my ($file) = @_;
    say path($file)->slurp;

    my $answer = prompt 'delete this file? [y/n]';
    return 1 if $answer eq "y";
    return;
}

sub del {
    my ($file) = @_;
    say `~/bin/del $file`;
}

~/bin/delは、$fileを.Trash/nnnnnn に移動させるルッビースクリプトです。