From d0d52613b9d039fcbe1f28de7b94eeb5cdc56265 Mon Sep 17 00:00:00 2001 From: Mark Nipper Date: Sat, 9 Nov 2024 23:49:55 -0800 Subject: Add helpful shell commands --- home/nipsy/common/core/zsh/zshrc | 17 ++++++++++++++--- home/root/common/core/zsh/default.nix | 1 + home/root/common/core/zsh/zshrc | 11 +++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/home/nipsy/common/core/zsh/zshrc b/home/nipsy/common/core/zsh/zshrc index 5c72aad..543450d 100644 --- a/home/nipsy/common/core/zsh/zshrc +++ b/home/nipsy/common/core/zsh/zshrc @@ -51,14 +51,25 @@ autoload -U edit-command-line zle -N edit-command-line bindkey -M vicmd v edit-command-line -# useful helper functions -function nix-file-list { find $(nix build ${1} --print-out-paths --no-link) } - # always open tmux if interactive [[ $- != *i* ]] && return #[[ -z "$TMUX" ]] && (tmux -2 new-session -t default \; new-window || tmux -2 new-session -s default) [[ -z "$TMUX" ]] && (tmux -2 attach -t default || tmux -2 new-session -s default) +# useful helper functions +function nix-file-list { find $(nix build ${1} --print-out-paths --no-link) } + +function ntrace { + + if [[ -z ${argv} ]]; then + echo 'you must specify a command to strace!' >&2 + return 1 + fi + + eval strace -f -e trace=network -s 10000 ${=argv[@]} + +} + # prompt/theme shit function precmd { diff --git a/home/root/common/core/zsh/default.nix b/home/root/common/core/zsh/default.nix index 5fe88b2..eaec714 100644 --- a/home/root/common/core/zsh/default.nix +++ b/home/root/common/core/zsh/default.nix @@ -27,6 +27,7 @@ export COLORFGBG=";0" ll = "ls -alFhs --color=auto"; nix-list-derivations = "nix-store --query --requisites /run/current-system | cut -d- -f2- | sort | uniq"; nix-list-generations = "nixos-rebuild list-generations | cat; echo; nix-env --list-generations --profile /nix/var/nix/profiles/system"; + pstrace = "bpftrace -e 'tracepoint:syscalls:sys_enter_exec*{ printf(\"pid: %d, comm: %s, args: \", pid, comm); join(args->argv); }'"; zgrep = "zgrep --color=auto"; }; }; diff --git a/home/root/common/core/zsh/zshrc b/home/root/common/core/zsh/zshrc index a0f7fee..28284f8 100644 --- a/home/root/common/core/zsh/zshrc +++ b/home/root/common/core/zsh/zshrc @@ -61,6 +61,17 @@ function nix-depends { } +function ntrace { + + if [[ -z ${argv} ]]; then + echo 'you must specify a command to strace!' >&2 + return 1 + fi + + eval strace -f -e trace=network -s 10000 ${=argv[@]} + +} + # prompt/theme shit function precmd { -- cgit v1.2.3