a1847dc860b85a0f0d97126ffe4b9b3a5276d1c1

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

style(sudo): apply main style guide indentation

Diff

 1diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
 2index f2445a7624739b82f6a7fa464e6e16444f725677..f0a01bc1f37e1ca132b923a21affcf0e48e69bee 100644
 3--- a/plugins/sudo/sudo.plugin.zsh
 4+++ b/plugins/sudo/sudo.plugin.zsh
 5@@ -15,48 +15,48 @@
 6 # ------------------------------------------------------------------------------
 7 
 8 __sudo-replace-buffer() {
 9-    local old=$1 new=$2 space=${2:+ }
10-    if [[ ${#LBUFFER} -le ${#old} ]]; then
11-        RBUFFER="${space}${BUFFER#$old }"
12-        LBUFFER="${new}"
13-    else
14-        LBUFFER="${new}${space}${LBUFFER#$old }"
15-    fi
16+  local old=$1 new=$2 space=${2:+ }
17+  if [[ ${#LBUFFER} -le ${#old} ]]; then
18+    RBUFFER="${space}${BUFFER#$old }"
19+    LBUFFER="${new}"
20+  else
21+    LBUFFER="${new}${space}${LBUFFER#$old }"
22+  fi
23 }
24 
25 sudo-command-line() {
26-    [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
27+  [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
28 
29-    # Save beginning space
30-    local WHITESPACE=""
31-    if [[ ${LBUFFER:0:1} = " " ]]; then
32-        WHITESPACE=" "
33-        LBUFFER="${LBUFFER:1}"
34-    fi
35+  # Save beginning space
36+  local WHITESPACE=""
37+  if [[ ${LBUFFER:0:1} = " " ]]; then
38+    WHITESPACE=" "
39+    LBUFFER="${LBUFFER:1}"
40+  fi
41 
42-    # Get the first part of the typed command and check if it's an alias to $EDITOR
43-    # If so, locally change $EDITOR to the alias so that it matches below
44-    if [[ -n "$EDITOR" ]]; then
45-        local cmd="${${(Az)BUFFER}[1]}"
46-        if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then
47-            local EDITOR="$cmd"
48-        fi
49+  # Get the first part of the typed command and check if it's an alias to $EDITOR
50+  # If so, locally change $EDITOR to the alias so that it matches below
51+  if [[ -n "$EDITOR" ]]; then
52+    local cmd="${${(Az)BUFFER}[1]}"
53+    if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then
54+      local EDITOR="$cmd"
55     fi
56+  fi
57 
58-    if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then
59-        __sudo-replace-buffer "$EDITOR" "sudoedit"
60-    elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then
61-        __sudo-replace-buffer "\$EDITOR" "sudoedit"
62-    elif [[ $BUFFER = sudoedit\ * ]]; then
63-        __sudo-replace-buffer "sudoedit" "$EDITOR"
64-    elif [[ $BUFFER = sudo\ * ]]; then
65-        __sudo-replace-buffer "sudo" ""
66-    else
67-        LBUFFER="sudo $LBUFFER"
68-    fi
69+  if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then
70+    __sudo-replace-buffer "$EDITOR" "sudoedit"
71+  elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then
72+    __sudo-replace-buffer "\$EDITOR" "sudoedit"
73+  elif [[ $BUFFER = sudoedit\ * ]]; then
74+    __sudo-replace-buffer "sudoedit" "$EDITOR"
75+  elif [[ $BUFFER = sudo\ * ]]; then
76+    __sudo-replace-buffer "sudo" ""
77+  else
78+    LBUFFER="sudo $LBUFFER"
79+  fi
80 
81-    # Preserve beginning space
82-    LBUFFER="${WHITESPACE}${LBUFFER}"
83+  # Preserve beginning space
84+  LBUFFER="${WHITESPACE}${LBUFFER}"
85 }
86 
87 zle -N sudo-command-line