diff --git a/.config/zsh/plugins/functionsPost.zsh b/.config/zsh/plugins/functionsPost.zsh index 48d19c9..5c3a956 100644 --- a/.config/zsh/plugins/functionsPost.zsh +++ b/.config/zsh/plugins/functionsPost.zsh @@ -308,23 +308,39 @@ function histgrep() { grep "$@" "${HISTFILE:-$HOME/.zsh_history}" } -function cformat() { - # TODO: respect manual changes made in meld - CLANG_FORMAT_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/clang/config" - FORMAT="$( - sed -E '/^\s*($|#)/d' "$CLANG_FORMAT_FILE" \ - | tr '\n' ',' \ - | sed 's/,$//' - )" - FORMAT="{${FORMAT}}" - if [ $# -eq 1 ]; then - meld <(clang-format -style="$FORMAT" $1) $1 +function clang-format() { + local idx=${@[(I)-style*]} + if (( ! idx )); then + # No style flag given + command clang-format "$@" + return fi - echo -n "Are you happy? [yn] " - read yn - if [ $yn = "y" ]; then - clang-format -i -style="$FORMAT" $1 + + local style="${@[$idx]#-style}" prefix="" + if [ -n "$style" ]; then + # Flag was given in form -style=