Improve compatibility with older versions of zsh (part 2)
This commit is contained in:
parent
f26719d7ac
commit
8e372241d8
|
@ -24,7 +24,7 @@ case $dir in west|south|north|east) ;;
|
|||
exit 1
|
||||
esac
|
||||
|
||||
if [[ $leap ]]; then
|
||||
if [[ -n $leap ]]; then
|
||||
# jump to monitor in direction
|
||||
bspc monitor -f "$dir"
|
||||
else
|
||||
|
|
|
@ -26,7 +26,7 @@ case $dir in west|south|north|east) ;;
|
|||
exit 1
|
||||
esac
|
||||
|
||||
if [[ $leap ]]; then
|
||||
if [[ -n $leap ]]; then
|
||||
# move window to monitor in direction
|
||||
old_id=$(bspc query -N -n focused)
|
||||
if [[ $(bspc query -M -m "$dir") ]]; then
|
||||
|
@ -38,7 +38,7 @@ else
|
|||
old_id=$(bspc query -N -n focused)
|
||||
if bspc node -s "$dir.local"; then
|
||||
bspc node -f "$old_id"
|
||||
elif [[ $(bspc query -M -m "$dir") ]]; then
|
||||
elif [[ -n $(bspc query -M -m "$dir") ]]; then
|
||||
bspc node -m "$dir"
|
||||
bspc node -f "$old_id"
|
||||
fi
|
||||
|
|
|
@ -7,7 +7,7 @@ if command -v xdg-open >/dev/null; then
|
|||
open=xdg-open
|
||||
elif command -v open >/dev/null; then
|
||||
open=open
|
||||
elif [[ $BROWSER ]]; then
|
||||
elif [[ -n $BROWSER ]]; then
|
||||
open=firefox
|
||||
else
|
||||
>&2 echo "No program to open urls with"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
# Get firefox's current url; requires "Hostname in title" plugin for firefox
|
||||
win=$(xdotool getactivewindow)
|
||||
if [[ $win ]]; then
|
||||
if [[ -n $win ]]; then
|
||||
winname=$(xdotool getwindowname $win)
|
||||
if [[ $winname =~ " - Mozilla Firefox$" ]]; then
|
||||
url=${winname% - Mozilla*}
|
||||
|
@ -26,4 +26,4 @@ urxvt -name urxvt-fuzzy \
|
|||
-e $SHELL \
|
||||
-c "fzf-pass $@ $url"
|
||||
|
||||
[[ $win ]] && xdotool windowactivate $win
|
||||
[[ -n $win ]] && xdotool windowactivate $win
|
||||
|
|
|
@ -3,7 +3,7 @@ SCRID=urxvt-scratch
|
|||
focused=$(xdotool getactivewindow)
|
||||
scratch=$(xdotool search --onlyvisible --classname $SCRID)
|
||||
|
||||
if [[ $scratch ]]; then
|
||||
if [[ -n $scratch ]]; then
|
||||
if [[ $focused == $scratch ]]; then
|
||||
tmux kill-session -t scratch
|
||||
else
|
||||
|
|
|
@ -4,7 +4,7 @@ if (($# == 0)); then
|
|||
data=$(amixer get Master)
|
||||
vol=$(echo "$data" | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p' | uniq)
|
||||
state=$(echo "$data" | grep '\[on\]')
|
||||
[[ $state ]] && echo $vol || echo 0
|
||||
[[ -n $state ]] && echo $vol || echo 0
|
||||
exit
|
||||
fi
|
||||
|
||||
|
|
|
@ -41,13 +41,13 @@ pac dosfstools ntfs-3g exfat-utils hfsprogs
|
|||
|
||||
# networking support
|
||||
WIRELESS_DEV=$(ip link | grep wlp | awk '{print $2}'| sed 's/://' | sed '1!d')
|
||||
if [[ $WIRELESS_DEV ]]; then
|
||||
if [[ -n $WIRELESS_DEV ]]; then
|
||||
echo "==> ${WIRELESS_DEV} interface detected"
|
||||
pac iw wireless_tools wpa_actiond wpa_supplicant dialog netctl
|
||||
fi
|
||||
|
||||
WIRED_DEV=$(ip link | grep "en[sop]" | awk '{print $2}'| sed 's/://' | sed '1!d')
|
||||
if [[ $WIRED_DEV ]]; then
|
||||
if [[ -n $WIRED_DEV ]]; then
|
||||
echo "==> ${WIRED_DEV} interface detected"
|
||||
arch "systemctl enable dhcpcd@${WIRED_DEV}.service"
|
||||
fi
|
||||
|
|
|
@ -46,14 +46,14 @@ done
|
|||
shift $((OPTIND-1))
|
||||
|
||||
cmds=( optipng jpegtran gifsicle )
|
||||
[[ $lossy ]] && cmds=( $cmds pngquant jpegoptim )
|
||||
[[ -n $lossy ]] && cmds=( $cmds pngquant jpegoptim )
|
||||
for cmd in ${cmds[@]}; do
|
||||
if ! command -v $cmd >/dev/null; then
|
||||
>&2 echo "$cmd isn't installed"
|
||||
error=1
|
||||
fi
|
||||
done
|
||||
if [[ $error ]]; then
|
||||
if [[ -n $error ]]; then
|
||||
>&2 echo "There were errors, aborting"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -65,14 +65,14 @@ for file in $@; do
|
|||
pre_size=$(_filesize "$file")
|
||||
case ${file##*.} in
|
||||
png)
|
||||
[[ $lossy ]] && pngquant $file
|
||||
[[ -n $lossy ]] && pngquant $file
|
||||
optipng -nc -nb -o7 $file
|
||||
;;
|
||||
gif)
|
||||
gifsicle --batch --optimize=3 "$file"
|
||||
;;
|
||||
jpg|jpeg)
|
||||
[[ $lossy ]] && jpegoptim --max=90 "$file"
|
||||
[[ -n $lossy ]] && jpegoptim --max=90 "$file"
|
||||
jpegtran -copy none -optimize -progressive -outfile "$file" "$file"
|
||||
;;
|
||||
*)
|
||||
|
|
2
bin/myip
2
bin/myip
|
@ -6,7 +6,7 @@ if [[ $1 == -w ]]; then
|
|||
shift
|
||||
fi
|
||||
|
||||
if [[ $wan ]]; then
|
||||
if [[ -n $wan ]]; then
|
||||
dig +short myip.opendns.com @resolver1.opendns.com
|
||||
else
|
||||
IF=$(netstat -rn | awk '/^0.0.0.0/ {thif=substr($0,74,10); print thif;} /^default.*UG/ {thif=substr($0,65,10); print thif;}')
|
||||
|
|
|
@ -33,7 +33,7 @@ done
|
|||
shift $((OPTIND-1))
|
||||
|
||||
target="$1"
|
||||
if [[ $target ]]; then
|
||||
if [[ -n $target ]]; then
|
||||
if [[ -t 0 ]]; then
|
||||
pb | $bin $target
|
||||
else
|
||||
|
|
10
bin/sup
10
bin/sup
|
@ -65,17 +65,17 @@ delay() {
|
|||
}
|
||||
|
||||
screenshot() {
|
||||
if [[ $doFullscreen ]]; then
|
||||
if [[ -n $doFullscreen ]]; then
|
||||
cap_fullscreen
|
||||
elif [[ $doSelection ]]; then
|
||||
elif [[ -n $doSelection ]]; then
|
||||
cap_selection &>/dev/null
|
||||
if ! [[ -s $local_file ]]; then
|
||||
$(rm "$local_file" 2> /dev/null)
|
||||
exit
|
||||
fi
|
||||
elif [[ $doWindow ]]; then
|
||||
elif [[ -n $doWindow ]]; then
|
||||
cap_window
|
||||
elif [[ $doURL ]]; then
|
||||
elif [[ -n $doURL ]]; then
|
||||
local urlext
|
||||
if [[ -f /usr/share/mime/globs ]]; then
|
||||
urlext=$(curl -sf --head "${remoteURL}" | grep 'Content-Type: ' | head -1 | grep -Po '(?<=\ )[^\;]*')
|
||||
|
@ -147,7 +147,7 @@ upload() {
|
|||
shortenerResult="$(curl -sf -F c=@- "${shortenerURL}" <<< "${uploadResult}")"
|
||||
fi
|
||||
|
||||
if [[ $shortener ]]; then
|
||||
if [[ -n $shortener ]]; then
|
||||
finalResult="$shortenerResult"
|
||||
else
|
||||
finalResult="$uploadResult"
|
||||
|
|
|
@ -9,7 +9,7 @@ install() {
|
|||
}
|
||||
|
||||
update() {
|
||||
if [[ $LUAENV_ROOT ]]; then
|
||||
if [[ -n $LUAENV_ROOT ]]; then
|
||||
cd $LUAENV_ROOT && git pull
|
||||
for ver in $LUAENV_ROOT/plugins/*(/); do
|
||||
cd $ver && git pull
|
||||
|
|
|
@ -8,7 +8,7 @@ install() {
|
|||
}
|
||||
|
||||
update() {
|
||||
if [[ $NODENV_ROOT ]]; then
|
||||
if [[ -n $NODENV_ROOT ]]; then
|
||||
cd $NODENV_ROOT && git pull
|
||||
for ver in $NODENV_ROOT/plugins/*(/); do
|
||||
cd $ver && git pull
|
||||
|
|
|
@ -7,7 +7,7 @@ install() {
|
|||
}
|
||||
|
||||
update() {
|
||||
if [[ $PYENV_ROOT ]]; then
|
||||
if [[ -n $PYENV_ROOT ]]; then
|
||||
cd $PYENV_ROOT && git pull
|
||||
for ver in $PYENV_ROOT/plugins/*(/N); do
|
||||
cd $ver && git pull
|
||||
|
|
|
@ -8,7 +8,7 @@ install() {
|
|||
}
|
||||
|
||||
update() {
|
||||
if [[ $RBENV_ROOT ]]; then
|
||||
if [[ -n $RBENV_ROOT ]]; then
|
||||
cd $RBENV_ROOT && git pull
|
||||
for ver in $RBENV_ROOT/plugins/*(/N); do
|
||||
cd $ver && git pull
|
||||
|
|
|
@ -8,11 +8,11 @@ FZF_DEFAULT_OPTS="--prompt='open > ' $FZF_DEFAULT_OPTS"
|
|||
case $OSTYPE in
|
||||
darwin*)
|
||||
cmd=$(find -L {,~}/Applications -iname '*.app' -maxdepth 2 -type d 2>/dev/null | sort -u | fzf)
|
||||
[[ $cmd ]] && open "$cmd"
|
||||
[[ -n $cmd ]] && open "$cmd"
|
||||
;;
|
||||
linux*)
|
||||
cmd=$(echo -n "$PATH" | xargs -d: -I{} -r -- find -L {} -maxdepth 1 -mindepth 1 -type f -executable -printf '%P\n' 2>/dev/null | sort -u | fzf)
|
||||
if [[ ! $cmd ]]; then
|
||||
if [[ -z $cmd ]]; then
|
||||
return
|
||||
elif [[ $cmd == fzf-* ]]; then
|
||||
$cmd
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
|
||||
|
||||
if [[ $pid ]]; then
|
||||
if [[ -n $pid ]]; then
|
||||
xargs kill -${1:-9} <<< "$pid"
|
||||
fi
|
||||
|
|
|
@ -8,4 +8,4 @@ set -e
|
|||
|
||||
song=$(mpc -f "%position%) %artist% - %title%" playlist)
|
||||
song_index=$(fzf --query="$1" --select-1 --exit-0 --prompt='play > ' <<<"$song" | sed -n 's/^\([0-9]\+\)).*/\1/p')
|
||||
[[ $song_index ]] && mpc -q play "$song_index"
|
||||
[[ -n $song_index ]] && mpc -q play "$song_index"
|
||||
|
|
|
@ -16,7 +16,7 @@ fi
|
|||
url=$@
|
||||
|
||||
LAST_ENTRY_FILE=/tmp/_upm
|
||||
if [[ $resume && -f $LAST_ENTRY_FILE ]]; then
|
||||
if [[ -n $resume && -f $LAST_ENTRY_FILE ]]; then
|
||||
entry="$(<$LAST_ENTRY_FILE)"
|
||||
last=1
|
||||
else
|
||||
|
@ -34,7 +34,7 @@ fi
|
|||
|
||||
echo "$entry" >/tmp/_upm
|
||||
secrets="$(pass show "$entry")"
|
||||
if [[ $secrets ]]; then
|
||||
if [[ -n $secrets ]]; then
|
||||
fields=$(awk -F': ' 'NR>1 && !/^otpauth:/ {print $1}' <<<"$secrets")
|
||||
field=$(printf "password\n%s\notp\n" "${fields[@]}" | fzf --prompt="pass ($entry) > ")
|
||||
case $field in
|
||||
|
|
|
@ -34,7 +34,7 @@ case $(grep "$file" "$playlist_dir"/*-star.m3u) in
|
|||
*/4-star.m3u:*) starn=4 ;;
|
||||
*/5-star.m3u:*) starn=5 ;;
|
||||
esac
|
||||
if [[ $starn ]]; then
|
||||
if [[ -n $starn ]]; then
|
||||
star_filled_icon="★"
|
||||
star_empty_icon="☆"
|
||||
if [[ $OSTYPE == linux* ]]; then
|
||||
|
@ -53,12 +53,12 @@ fi
|
|||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
[[ $rating ]] && rating="[$rating] "
|
||||
[[ -n $rating ]] && rating="[$rating] "
|
||||
killall terminal-notifier
|
||||
terminal-notifier -title "$rating$title" -message "by $artist :: $album" -appIcon "/Applications/iTunes.app/Contents/Resources/iTunes.icns" &
|
||||
;;
|
||||
linux*)
|
||||
[[ $rating ]] && rating="$rating<br />"
|
||||
[[ -n $rating ]] && rating="$rating<br />"
|
||||
notify-send --urgency=low --icon="media-playback-start" --app-name="ncmpcpp" "$rating<b>$title</b>" "${artist}\n<i>${album}</i>" &
|
||||
;;
|
||||
esac >/dev/null 2>&1
|
||||
|
|
|
@ -9,7 +9,7 @@ install() {
|
|||
debian) sudo apt-get install -y tmux ;;
|
||||
esac
|
||||
|
||||
[[ $TMUXIFIER ]] && _ensure_repo jimeh/tmuxifier $TMUXIFIER
|
||||
[[ -n $TMUXIFIER ]] && _ensure_repo jimeh/tmuxifier $TMUXIFIER
|
||||
}
|
||||
|
||||
update() {
|
||||
|
|
|
@ -3,7 +3,7 @@ alias tmux='tmux -f "$TMUX_HOME/tmux.conf"'
|
|||
alias ta='tmux attach'
|
||||
alias tl='tmux ls'
|
||||
|
||||
if [[ $TMUX ]]; then # From inside tmux
|
||||
if [[ -n $TMUX ]]; then # From inside tmux
|
||||
alias tf='tmux find-window'
|
||||
# Detach all other clients to this session
|
||||
alias mine='tmux detach -a'
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
id=$(echo $TMUX | sed 's/.*,//g')
|
||||
res=$(tmux ls -F '#{session_id}:#{session_name}' | grep -e "^\$$id:")
|
||||
|
||||
[[ $res ]] || exit 1
|
||||
[[ -z $res ]] && exit 1
|
||||
echo "${res#\$$id:}"
|
||||
|
|
|
@ -23,13 +23,13 @@ prompt_git_dirty() {
|
|||
prompt_hook_precmd() {
|
||||
vcs_info # get git info
|
||||
# Newline before prompt, except on init
|
||||
[[ $PROMPT_DONE ]] && print ""; PROMPT_DONE=1
|
||||
[[ -n $PROMPT_DONE ]] && print ""; PROMPT_DONE=1
|
||||
}
|
||||
|
||||
## Initialization ######################
|
||||
prompt_init() {
|
||||
# prevent the extra space in the rprompt
|
||||
[[ $EMACS ]] || ZLE_RPROMPT_INDENT=0
|
||||
[[ -n $EMACS ]] || ZLE_RPROMPT_INDENT=0
|
||||
# prevent percentage showing up
|
||||
# if output doesn't end with a newline
|
||||
export PROMPT_EOL_MARK=
|
||||
|
@ -59,7 +59,7 @@ prompt_init() {
|
|||
zstyle ':vcs_info:git*' actionformats ' %b (%a)'
|
||||
|
||||
# show username@host if logged in through SSH
|
||||
if [[ $SSH_CONNECTION ]]; then
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
prompt_username='%m '
|
||||
if [[ $(whoami) != hlissner ]]; then
|
||||
prompt_username="%n.$prompt_username"
|
||||
|
|
Loading…
Reference in a new issue