diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cli.zsh | 30 | ||||
-rw-r--r-- | lib/clipboard.zsh | 24 | ||||
-rw-r--r-- | lib/misc.zsh | 4 |
3 files changed, 29 insertions, 29 deletions
diff --git a/lib/cli.zsh b/lib/cli.zsh index b71f6d9ce..db659c11f 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -280,9 +280,10 @@ multi == 1 && length(\$0) > 0 { " local zdot="${ZDOTDIR:-$HOME}" - awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \ - && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \ - && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc" + local zshrc="${${:-"${zdot}/.zshrc"}:A}" + awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \ + && command cp -f "$zshrc" "$zdot/.zshrc.bck" \ + && command mv -f "$zdot/.zshrc.new" "$zshrc" # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -294,8 +295,7 @@ multi == 1 && length(\$0) > 0 { # Exit if the new .zshrc file has syntax errors if ! command zsh -n "$zdot/.zshrc"; then _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..." - command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new" - command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc" + command mv -f "$zdot/.zshrc.bck" "$zshrc" return 1 fi @@ -354,9 +354,10 @@ multi == 1 && /^[^#]*\)/ { " local zdot="${ZDOTDIR:-$HOME}" - awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \ - && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \ - && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc" + local zshrc="${${:-"${zdot}/.zshrc"}:A}" + awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \ + && command cp -f "$zshrc" "$zdot/.zshrc.bck" \ + && command mv -f "$zdot/.zshrc.new" "$zshrc" # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -368,8 +369,7 @@ multi == 1 && /^[^#]*\)/ { # Exit if the new .zshrc file has syntax errors if ! command zsh -n "$zdot/.zshrc"; then _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..." - command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new" - command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc" + command mv -f "$zdot/.zshrc.bck" "$zshrc" return 1 fi @@ -715,7 +715,8 @@ END { ' local zdot="${ZDOTDIR:-$HOME}" - awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \ + local zshrc="${${:-"${zdot}/.zshrc"}:A}" + awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \ || { # Prepend ZSH_THEME= line to .zshrc if it doesn't exist cat <<EOF @@ -724,8 +725,8 @@ ZSH_THEME="$1" # set by \`omz\` EOF cat "$zdot/.zshrc" } > "$zdot/.zshrc.new" \ - && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \ - && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc" + && command cp -f "$zshrc" "$zdot/.zshrc.bck" \ + && command mv -f "$zdot/.zshrc.new" "$zshrc" # Exit if the new .zshrc file wasn't created correctly [[ $? -eq 0 ]] || { @@ -737,8 +738,7 @@ EOF # Exit if the new .zshrc file has syntax errors if ! command zsh -n "$zdot/.zshrc"; then _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..." - command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new" - command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc" + command mv -f "$zdot/.zshrc.bck" "$zshrc" return 1 fi diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 4e3ba0a45..ad83fc4b2 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -10,8 +10,8 @@ # - pbcopy, pbpaste (macOS) # - cygwin (Windows running Cygwin) # - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set) -# - xclip (if $DISPLAY is set) # - xsel (if $DISPLAY is set) +# - xclip (if $DISPLAY is set) # - lemonade (for SSH) https://github.com/pocke/lemonade # - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ # - win32yank (Windows) @@ -52,37 +52,37 @@ function detect-clipboard() { emulate -L zsh if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then - function clipcopy() { pbcopy < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; } function clippaste() { pbpaste; } elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clippaste() { cat /dev/clipboard; } elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then - function clipcopy() { wl-copy < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; } function clippaste() { wl-paste; } - elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then - function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; } - function clippaste() { xclip -out -selection clipboard; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then - function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; } function clippaste() { xsel --clipboard --output; } + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then + function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; } + function clippaste() { xclip -out -selection clipboard; } elif (( ${+commands[lemonade]} )); then - function clipcopy() { lemonade copy < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | lemonade copy; } function clippaste() { lemonade paste; } elif (( ${+commands[doitclient]} )); then - function clipcopy() { doitclient wclip < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | doitclient wclip; } function clippaste() { doitclient wclip -r; } elif (( ${+commands[win32yank]} )); then - function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | win32yank -i; } function clippaste() { win32yank -o; } elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then - function clipcopy() { termux-clipboard-set < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | termux-clipboard-set; } function clippaste() { termux-clipboard-get; } elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then function clipcopy() { tmux load-buffer "${1:--}"; } function clippaste() { tmux save-buffer -; } elif [[ $(uname -r) = *icrosoft* ]]; then - function clipcopy() { clip.exe < "${1:-/dev/stdin}"; } + function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } function clippaste() { powershell.exe -noprofile -command Get-Clipboard; } else function _retry_clipboard_detection_or_fail() { diff --git a/lib/misc.zsh b/lib/misc.zsh index a5d3af998..1f637083a 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -24,10 +24,10 @@ env_default 'LESS' '-R' ## super user alias alias _='sudo ' -## more intelligent acking for ubuntu users +## more intelligent acking for ubuntu users and no alias for users without ack if (( $+commands[ack-grep] )); then alias afind='ack-grep -il' -else +elif (( $+commands[ack] )); then alias afind='ack -il' fi |