Compare commits
2 Commits
d68d397f66
...
5347c71851
Author | SHA1 | Date |
---|---|---|
Bauke | 5347c71851 | |
Bauke | d00d878dc1 |
|
@ -29,5 +29,8 @@ alias clipboard-to-file="xclip -sel clip -o > $1"
|
|||
alias file-to-clipboard="xclip -sel clip -i $1"
|
||||
alias gpg-decrypt-clipboard="xclip -sel clip -o | gpg --decrypt"
|
||||
|
||||
# Video aliases.
|
||||
alias get-resolution="ffprobe -v error -select_streams v -show_entries stream=width,height -of csv=p=0:s=x"
|
||||
|
||||
# See '$BAUKE_DIR/Restic Backups.md' for information.
|
||||
alias restic-b2="source $BAUKE_DIR/data/restic-b2-credentials.zsh && restic"
|
||||
|
|
|
@ -15,10 +15,15 @@ export const runCommand = new Command()
|
|||
"--include-directories",
|
||||
"Include directories found inside the directories.",
|
||||
)
|
||||
.action(async ({ directory, includeDirectories }) => {
|
||||
.option(
|
||||
"--output-script",
|
||||
"Output the commands as a shell script instead of running them.",
|
||||
)
|
||||
.action(async ({ directory, includeDirectories, outputScript }) => {
|
||||
await actionHandler({
|
||||
directories: directory,
|
||||
includeDirectories: includeDirectories ?? false,
|
||||
outputScript: outputScript ?? false,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -26,6 +31,7 @@ async function actionHandler(
|
|||
options: {
|
||||
directories: string[];
|
||||
includeDirectories: boolean;
|
||||
outputScript: boolean;
|
||||
},
|
||||
): Promise<void> {
|
||||
let command: string[] = [];
|
||||
|
@ -135,6 +141,22 @@ async function actionHandler(
|
|||
continue;
|
||||
}
|
||||
|
||||
if (options.outputScript) {
|
||||
const defaultFilename = "bulk-run-script.zsh";
|
||||
const { filename } = await prompt.prompt([
|
||||
{
|
||||
type: prompt.Input,
|
||||
name: "filename",
|
||||
message: "Filename for the script",
|
||||
default: defaultFilename,
|
||||
},
|
||||
]);
|
||||
const commands = constructedCommands.map((c) => c.join(" ")).join("\n");
|
||||
await Deno.writeTextFile(
|
||||
filename ?? defaultFilename,
|
||||
`#!/usr/bin/env zsh\n\n${commands}`,
|
||||
);
|
||||
} else {
|
||||
console.log("\n## Output");
|
||||
for (const constructedCommand of constructedCommands) {
|
||||
await Deno.run({
|
||||
|
@ -143,3 +165,4 @@ async function actionHandler(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue