zsh:alias:clipboard: Check for commands existence
This commit is contained in:
@@ -46,17 +46,15 @@
|
|||||||
alias git-ancestor='git merge-base "$(git-base-branch)" HEAD'
|
alias git-ancestor='git merge-base "$(git-base-branch)" HEAD'
|
||||||
|
|
||||||
# Clipboard
|
# Clipboard
|
||||||
|
(( ! $+commands[perl] )) || SETCLIP_PREFIX="perl -pe 'chomp if eof' | "
|
||||||
if [[ $OSTYPE =~ darwin ]]; then
|
if [[ $OSTYPE =~ darwin ]]; then
|
||||||
alias getclip="pbpaste"
|
(( ! $+commands[pbpaste] )) || alias getclip="pbpaste"
|
||||||
SETCLIP_COMMAND="pbcopy"
|
(( ! $+commands[pbcopy] )) || alias setclip="${SETCLIP_PREFIX}pbcopy"
|
||||||
else
|
elif (( $+commands[xclip] )); then
|
||||||
alias getclip="xclip -selection c -o"
|
alias getclip="xclip -selection c -o"
|
||||||
SETCLIP_COMMAND="xclip -selection c"
|
alias setclip="${SETCLIP_PREFIX}xclip -selection c"
|
||||||
fi
|
fi
|
||||||
! command -v perl &>/dev/null \
|
unset SETCLIP_PREFIX
|
||||||
|| SETCLIP_COMMAND="perl -pe 'chomp if eof' | $SETCLIP_COMMAND"
|
|
||||||
alias setclip="$SETCLIP_COMMAND"
|
|
||||||
unset SETCLIP_COMMAND
|
|
||||||
|
|
||||||
# Save keystrokes and my memory
|
# Save keystrokes and my memory
|
||||||
alias la='ls -A'
|
alias la='ls -A'
|
||||||
|
|||||||
Reference in New Issue
Block a user