From 581995fd68b9b831982a70b4a92d66873df71c0a Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Wed, 8 Jan 2025 14:44:39 +0100 Subject: [PATCH] flamegraph zfunc --- .zsh/zfunc/_flamegraph | 110 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 .zsh/zfunc/_flamegraph diff --git a/.zsh/zfunc/_flamegraph b/.zsh/zfunc/_flamegraph new file mode 100644 index 0000000..09dc391 --- /dev/null +++ b/.zsh/zfunc/_flamegraph @@ -0,0 +1,110 @@ +_flamegraph() { + local i cur prev opts cmd + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cmd="" + opts="" + + for i in ${COMP_WORDS[@]} + do + case "${cmd},${i}" in + ",$1") + cmd="flamegraph" + ;; + *) + ;; + esac + done + + case "${cmd}" in + flamegraph) + opts="-p -v -o -F -c -i -h -V --pid --completions --verbose --output --open --root --freq --cmd --deterministic --inverted --reverse --notes --min-width --image-width --palette --skip-after --flamechart --ignore-status --no-inline --post-process --perfdata --help --version [TRAILING_ARGUMENTS]..." + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --pid) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -p) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --completions) + COMPREPLY=($(compgen -W "bash elvish fish powershell zsh" -- "${cur}")) + return 0 + ;; + --output) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -o) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --root) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --freq) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -F) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --cmd) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -c) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --notes) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --min-width) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --image-width) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --palette) + COMPREPLY=($(compgen -W "aqua blue green hot io java js mem orange perl python purple red rust wakeup yellow" -- "${cur}")) + return 0 + ;; + --skip-after) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --post-process) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --perfdata) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + esac +} + +if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then + complete -F _flamegraph -o nosort -o bashdefault -o default flamegraph +else + complete -F _flamegraph -o bashdefault -o default flamegraph +fi