pastebin script + go support
This commit is contained in:
parent
e1db3f73e2
commit
03e17cbd6b
1 changed files with 34 additions and 1 deletions
|
@ -2,7 +2,39 @@
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: {
|
}: let
|
||||||
|
wantgunsbin_script = pkgs.writeShellScriptBin "pst" ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
URL="https://pastebin.dessa.dev"
|
||||||
|
|
||||||
|
FILEPATH="$1"
|
||||||
|
FILENAME=$(basename -- "$FILEPATH")
|
||||||
|
EXTENSION="''${FILENAME##*.}"
|
||||||
|
|
||||||
|
if [ ! -f $FILEPATH ]; then
|
||||||
|
# curl the file from the internet, given the id
|
||||||
|
# future regex for any wantsgunbin link: ^((http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b\/)?[0-9a-zA-Z]{5,}(\..*)?$
|
||||||
|
if [[ $FILEPATH =~ ^(https:\/\/pastebin\.dessa\.dev\/)?[0-9a-zA-Z]{5,}(\..*)?$ ]]; then
|
||||||
|
OUT=$(mktemp)
|
||||||
|
echo $OUT
|
||||||
|
curl -sL https://pastebin.dessa.dev/$FILEPATH > $OUT
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "File not found: $FILEPATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
RESPONSE=$(curl --data-binary @''${FILEPATH:-/dev/stdin} --url $URL)
|
||||||
|
PASTELINK="$URL$RESPONSE"
|
||||||
|
|
||||||
|
[ -z "$EXTENSION" ] && echo $PASTELINK || echo $PASTELINK.$EXTENSION
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
programs.zsh.shellAliases = {
|
||||||
|
pst = "${wantgunsbin_script}/bin/pst";
|
||||||
|
};
|
||||||
home.packages = with pkgs.unstable; [
|
home.packages = with pkgs.unstable; [
|
||||||
bruno
|
bruno
|
||||||
just
|
just
|
||||||
|
@ -14,6 +46,7 @@
|
||||||
corepack
|
corepack
|
||||||
cargo-watch
|
cargo-watch
|
||||||
rustup
|
rustup
|
||||||
|
go
|
||||||
|
|
||||||
jetbrains.idea-community
|
jetbrains.idea-community
|
||||||
vscode
|
vscode
|
||||||
|
|
Loading…
Reference in a new issue