diff options
-rw-r--r-- | shellrc.d/alias | 4 | ||||
-rw-r--r-- | shellrc.d/dev | 75 |
2 files changed, 43 insertions, 36 deletions
diff --git a/shellrc.d/alias b/shellrc.d/alias index 5e412a3..c84c83a 100644 --- a/shellrc.d/alias +++ b/shellrc.d/alias @@ -33,7 +33,3 @@ fi if command -v sdcv 2>/dev/null >&2; then alias sdcv='sdcv -c' fi - -if command -v nix 2>/dev/null >&2; then - alias nrun='nix run .' -fi diff --git a/shellrc.d/dev b/shellrc.d/dev index e66369c..0fa462e 100644 --- a/shellrc.d/dev +++ b/shellrc.d/dev @@ -1,6 +1,5 @@ # vim: ft=sh: - if command -v valgrind >/dev/null; then alias memcheck="valgrind --track-fds=yes --leak-check=full --track-origins=yes" @@ -10,48 +9,49 @@ if command -v valgrind >/dev/null; then fi - if command -v meson >/dev/null; then -_meson_setup() { - if [ ! -f "build/build.ninja" ]; then - meson setup -Doptimization=plain build - fi -} + msetup() { + set -- "-Doptimization=plain" "$@" + if [[ -f "build/build.ninja" ]]; then + [[ $# -eq 0 ]] || + meson configure build "$@" + else + meson setup "$@" build + fi + } -mbuild() { - _meson_setup \ - && meson compile -C build "$@" -} + mbuild() { + msetup && + meson compile -C build "$@" + } -mtest() { - _meson_setup \ - && meson test -C build "$@" -} + mtest() { + msetup && + meson test -C build "$@" + } -mcoverage() { - _meson_setup \ - && meson configure build -Db_coverage=true \ - && meson test -C build "$@" \ - && ninja -C build coverage-html -} + mcoverage() { + msetup -Db_coverage=true && + meson test -C build "$@" && + ninja -C build coverage-html + } -mdist() { - _meson_setup \ - && meson dist -C build --formats xztar,gztar,zip "$@" -} + mdist() { + msetup && + meson dist -C build --formats xztar,gztar,zip "$@" + } -mupdate() { - meson subprojects update -} + mupdate() { + meson subprojects update + } -mpurge() { - meson subprojects purge -} + mpurge() { + meson subprojects purge + } fi - if command -v bear >/dev/null; then bmake() { @@ -70,3 +70,14 @@ glv() { nvim_config() ( cd ~/.config/nvim && nvim init.vim ) + +if command -v nix 2>/dev/null >&2; then + nrun() { + nix run . -- "$@" + } + nrun_() { + local package="$1" + shift + nix run ".#$package" -- "$@" + } +fi |