From 4506210c38774bc5da1a0495c2a911776cf6f2cb Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 19 Jun 2022 12:54:11 +0200 Subject: fix(lib): don't attach to tty in `wl-copy` and `xclip` (#10953) Fixes #10925 --- lib/clipboard.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 4e3ba0a45..272b41598 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -58,10 +58,10 @@ function detect-clipboard() { 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() { wl-copy < "${1:-/dev/stdin}" &>/dev/null &|; } function clippaste() { wl-paste; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then - function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; } + function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}" &>/dev/null &|; } function clippaste() { xclip -out -selection clipboard; } elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } -- cgit v1.2.3-70-g09d2 From 39573125e4971b34e26f4cb3aaa210a74ea6ca34 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 19 Jun 2022 12:49:32 +0200 Subject: feat(lib): wait for input to copy to the clipboard (#10953) --- lib/clipboard.zsh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 272b41598..aab21a28a 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -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}" &>/dev/null &|; } + 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}" &>/dev/null &|; } + function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; } 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 (( ${+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() { -- cgit v1.2.3-70-g09d2 From ef8e63a7fd30e04079e54ea76043c1db76e24ddf Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 12 Jul 2022 18:56:09 +0200 Subject: fix(lib): prefer `xsel` over `xclip` in clipboard.zsh See #10925 --- lib/clipboard.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index aab21a28a..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) @@ -60,12 +60,12 @@ function detect-clipboard() { elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; } function clippaste() { wl-paste; } - 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 [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then 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() { cat "${1:-/dev/stdin}" | lemonade copy; } function clippaste() { lemonade paste; } -- cgit v1.2.3-70-g09d2 From 0c7ce363c903e1e3255d4d30255ff4790678ace9 Mon Sep 17 00:00:00 2001 From: hellzbellz <31550512+Hellzbellz123@users.noreply.github.com> Date: Tue, 12 Jul 2022 10:36:43 -0700 Subject: chore(lib): only create `afind` alias if `ack` is installed (#11017) --- lib/misc.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3-70-g09d2 From 97134d1eed19b72a9c4bf90a2effa847221608bf Mon Sep 17 00:00:00 2001 From: Ben Walton Date: Tue, 2 Aug 2022 18:28:44 +0100 Subject: fix(cli): make `omz` honour symlinks when changing `.zshrc` (#11082) --- lib/cli.zsh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'lib') 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 < "$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 -- cgit v1.2.3-70-g09d2