@leptune
2024-08-04T19:07:17.000000Z
字数 2238
阅读 121
linux
alias pma='php D:/.pm-php/add.php'alias pmr='php D:/.pm-php/rename.php'alias pmd='php D:/.pm-php/del.php'alias pml='php D:/.pm-php/list.php'function pmg() {p=`php D:/.pm-php/go.php $1`if [[ $? == 0 ]]; thencd $p;echo 'succes!';pwdelseecho $p;fi}
<?phpif (count($argv) !== 2) {echo 'error: Usage: pma name'.PHP_EOL;exit(1);}$name = $argv[1];$cwd = getcwd();$data = [];$savePath = __DIR__ . '/' . '.pm.data.seri';if (file_exists($savePath)) {$data = unserialize(file_get_contents($savePath));}$data[$name] = $cwd;file_put_contents($savePath, serialize($data));echo 'success!'.PHP_EOL;exit(0);
<?phpif (count($argv) !== 2) {echo 'error: Usage: pmg name'.PHP_EOL;exit(1);}$name = $argv[1];$data = [];$savePath = __DIR__ . '/' . '.pm.data.seri';if (file_exists($savePath)) {$data = unserialize(file_get_contents($savePath));}if (!isset($data[$name])) {echo "error: $name not exist! add first!".PHP_EOL;exit(1);}if (!file_exists($data[$name])) {echo "error: path [{$data[$name]}] not exist, please check!".PHP_EOL;exit(1);}echo $data[$name];exit(0);
<?phpif (count($argv) !== 1) {echo 'error: Usage: pml'.PHP_EOL;exit(1);}$data = [];$savePath = __DIR__ . '/' . '.pm.data.seri';if (file_exists($savePath)) {$data = unserialize(file_get_contents($savePath));}if (empty($data)) {echo 'error: there is no path alias! please add first!'.PHP_EOL;exit(1);}echo PHP_EOL;foreach ($data as $name => $path) {echo "$name => $path".PHP_EOL;}echo PHP_EOL;echo 'success!'.PHP_EOL;exit(0);
<?phpif (count($argv) !== 2) {echo 'error: Usage: pmd name'.PHP_EOL;exit(1);}$name = $argv[1];$data = [];$savePath = __DIR__ . '/' . '.pm.data.seri';if (file_exists($savePath)) {$data = unserialize(file_get_contents($savePath));}if (!isset($data[$name])) {echo "error: $name not exist! add first!".PHP_EOL;exit(1);}unset($data[$name]);file_put_contents($savePath, serialize($data));echo 'success!'.PHP_EOL;exit(0);
<?phpif (count($argv) !== 3) {echo 'error: Usage: pmr old_name new_name'.PHP_EOL;exit(1);}$old_name = $argv[1];$new_name = $argv[2];$data = [];$savePath = __DIR__ . '/' . '.pm.data.seri';if (file_exists($savePath)) {$data = unserialize(file_get_contents($savePath));}if (!isset($data[$old_name])) {echo "error: $old_name not exist! add first!".PHP_EOL;exit(1);}$data[$new_name] = $data[$old_name];unset($data[$old_name]);file_put_contents($savePath, serialize($data));echo 'success!'.PHP_EOL;exit(0);