From 36b840f0da1f999f433fa5d2e5f1ea8e79afaa5c Mon Sep 17 00:00:00 2001 From: kake26 Date: Sun, 13 Apr 2025 21:44:48 -0500 Subject: [PATCH] save point --- Makefile.PL | 1 + lib/pshell_history.db | 0 pshell.pl | 11 ++++++++++- pshell_history.db | Bin 12288 -> 12288 bytes 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 lib/pshell_history.db diff --git a/Makefile.PL b/Makefile.PL index a838921..2ab0438 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -7,5 +7,6 @@ WriteMakefile( 'DBI' => 0, 'DBD::SQLite' => 0, 'Term::ReadLine' => 0, + 'Cwd' => 0, }, ); diff --git a/lib/pshell_history.db b/lib/pshell_history.db new file mode 100644 index 0000000..e69de29 diff --git a/pshell.pl b/pshell.pl index 61c61fd..8d91546 100755 --- a/pshell.pl +++ b/pshell.pl @@ -3,6 +3,7 @@ use lib 'lib'; use History::SQLite; use Term::ReadLine; +use Cwd; # Initialize command history my $history = History::SQLite->new( @@ -19,7 +20,8 @@ my @history = $history->get_all; $term->addhistory($_) for @history; while (1) { - my $prompt = "pshell> "; + my $cwd = getcwd(); + my $prompt = "pshell:$cwd> "; my $command = $term->readline($prompt); last unless defined $command; @@ -29,6 +31,13 @@ while (1) { # Skip empty commands next unless length $command; + # Handle cd command specially + if ($command =~ /^cd\s*(.*)/) { + my $dir = $1 || $ENV{HOME}; + chdir $dir or warn "Could not change to directory $dir: $!"; + next; + } + # Save command to history $history->add($command); $term->addhistory($command); diff --git a/pshell_history.db b/pshell_history.db index a24003c6f260fa556ae1dc2af645629f693bfb9a..de1059c637f2c4efe098988758e178c65d821ab9 100644 GIT binary patch delta 300 zcmZojXh@hK%_u)n#+gxmW5N=CW;vdc$?O8!LcDRjPQ2>8>^!e{PVubf>E|igSZKgw zDJjRoAZVOZY-C_$s%v1PYiOciU}R-tVr6J9CCkDfY+O*Df+lBRWo#iUGg(1SqTU3^ zHj|TPVUPwIp`e?Sn1QL*P+E$GLDaagG_wR%(%8bv#8OTYr)H46k)#AR_W`Ah&85W6 bKn^TdD913@*g#4Qmzs<=Nr delta 36 scmZojXh@hK%_ufe#+gxUW5N=CW>Ma%$?O8!8w)*nH&@BF3NeZT0LH!wFaQ7m