Add more shell combinators
This commit is contained in:
parent
49157d618d
commit
ba81aca285
@ -28,8 +28,18 @@ let
|
|||||||
apply = f: concatStringsSep " | " f.value;
|
apply = f: concatStringsSep " | " f.value;
|
||||||
stringify = f: concatStringsSep (blue "\n| ") f.value;
|
stringify = f: concatStringsSep (blue "\n| ") f.value;
|
||||||
};
|
};
|
||||||
join = {
|
shellAnd = {
|
||||||
wrap = genWrapper "join";
|
wrap = genWrapper "shellAnd";
|
||||||
|
apply = f: concatStringsSep " && " f.value;
|
||||||
|
stringify = f: concatStringsSep (blue "\n&& ") f.value;
|
||||||
|
};
|
||||||
|
shellThen = {
|
||||||
|
wrap = genWrapper "shellThen";
|
||||||
|
apply = f: concatStringsSep "; " f.value;
|
||||||
|
stringify = f: concatStringsSep (blue ";\n ") f.value;
|
||||||
|
};
|
||||||
|
shellJoin = {
|
||||||
|
wrap = genWrapper "shellJoin";
|
||||||
apply = f: concatStringsSep " " f.value;
|
apply = f: concatStringsSep " " f.value;
|
||||||
stringify = f: concatStringsSep " \\\n " f.value;
|
stringify = f: concatStringsSep " \\\n " f.value;
|
||||||
};
|
};
|
||||||
@ -49,7 +59,9 @@ in rec {
|
|||||||
_module.args.shellOptions = {
|
_module.args.shellOptions = {
|
||||||
aliases = let
|
aliases = let
|
||||||
shellPipe = functors.shellPipe.wrap;
|
shellPipe = functors.shellPipe.wrap;
|
||||||
join = functors.join.wrap;
|
shellJoin = functors.shellJoin.wrap;
|
||||||
|
shellAnd = functors.shellAnd.wrap;
|
||||||
|
shellThen = functors.shellThen.wrap;
|
||||||
in with pkgs; {
|
in with pkgs; {
|
||||||
|
|
||||||
# ░█▀▄░█▀▀░█▀█░█░░░█▀█░█▀▀░█▀▀░█▄█░█▀▀░█▀█░▀█▀░█▀▀
|
# ░█▀▄░█▀▀░█▀█░█░░░█▀█░█▀▀░█▀▀░█▄█░█▀▀░█▀█░▀█▀░█▀▀
|
||||||
@ -153,8 +165,8 @@ in rec {
|
|||||||
"grep \"${config.services.dropbox.path}/[^.]\""
|
"grep \"${config.services.dropbox.path}/[^.]\""
|
||||||
];
|
];
|
||||||
|
|
||||||
subdirs-to-cbz = join [
|
subdirs-to-cbz = shellJoin [
|
||||||
"for dir in \"./*\"; do"
|
"for dir in \"./*\";"
|
||||||
" ${zip}/bin/zip -r \"$dir.cbz\" \"$d\";"
|
" ${zip}/bin/zip -r \"$dir.cbz\" \"$d\";"
|
||||||
"done"
|
"done"
|
||||||
];
|
];
|
||||||
@ -212,6 +224,11 @@ in rec {
|
|||||||
# Having 'watch' with a space after as an alias, enables it to expand other aliases
|
# Having 'watch' with a space after as an alias, enables it to expand other aliases
|
||||||
watch = "${procps}/bin/watch ";
|
watch = "${procps}/bin/watch ";
|
||||||
|
|
||||||
|
concatPdfs = shellThen [
|
||||||
|
"echo \"${lib.termColors.front.red "Concatenating all pdfs in current directory to 'out.pdf'"}\""
|
||||||
|
"${poppler_utils}/bin/pdfunite *.pdf out.pdf"
|
||||||
|
];
|
||||||
|
|
||||||
m = "${ncmpcpp}/bin/ncmpcpp";
|
m = "${ncmpcpp}/bin/ncmpcpp";
|
||||||
p = "${python39Packages.ipython}/bin/ipython";
|
p = "${python39Packages.ipython}/bin/ipython";
|
||||||
};
|
};
|
||||||
@ -223,14 +240,14 @@ in rec {
|
|||||||
# I didn't know where else to put these ¯\_(ツ)_/¯
|
# I didn't know where else to put these ¯\_(ツ)_/¯
|
||||||
|
|
||||||
"Misc" = {
|
"Misc" = {
|
||||||
youtube-dl-list = join [
|
youtube-dl-list = shellJoin [
|
||||||
"${youtube-dl}/bin/youtube-dl"
|
"${youtube-dl}/bin/youtube-dl"
|
||||||
"-f \"bestvideo[ext=mp4]+bestaudio[e=m4a]/bestvideo+bestaudio\""
|
"-f \"bestvideo[ext=mp4]+bestaudio[e=m4a]/bestvideo+bestaudio\""
|
||||||
"-o \"%(playlist_index)s-%(title)s.%(ext)s\""
|
"-o \"%(playlist_index)s-%(title)s.%(ext)s\""
|
||||||
];
|
];
|
||||||
|
|
||||||
music-dl = "${youtube-dl}/bin/youtube-dl --extract-audio -f \"bestaudio[ext=m4a]/best\"";
|
music-dl = "${youtube-dl}/bin/youtube-dl --extract-audio -f \"bestaudio[ext=m4a]/best\"";
|
||||||
music-dl-list = join [
|
music-dl-list = shellJoin [
|
||||||
"${youtube-dl}/bin/youtube-dl"
|
"${youtube-dl}/bin/youtube-dl"
|
||||||
"--extract-audio"
|
"--extract-audio"
|
||||||
"-f \"bestaudio[ext=m4a]/best\""
|
"-f \"bestaudio[ext=m4a]/best\""
|
||||||
@ -294,7 +311,7 @@ in rec {
|
|||||||
# TODO: flatten functions
|
# TODO: flatten functions
|
||||||
functions = {
|
functions = {
|
||||||
all = {
|
all = {
|
||||||
md-to-pdf = functors.join.wrap [
|
md-to-pdf = functors.shellJoin.wrap [
|
||||||
"pandoc \"$1\""
|
"pandoc \"$1\""
|
||||||
"-f gfm"
|
"-f gfm"
|
||||||
"-V linkcolor:blue"
|
"-V linkcolor:blue"
|
||||||
|
Loading…
Reference in New Issue
Block a user