1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-02-12 05:49:47 +08:00

Compare commits

..

No commits in common. "38e80e9f21ee981b5f616003c788dcbb9267466c" and "e6a1db213d66efdaec00469e58d4f9f3f2a78bd0" have entirely different histories.

2 changed files with 20 additions and 13 deletions

View File

@ -52,10 +52,10 @@ function bgnotify_formatted {
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
if [[ $exit_status -eq 0 ]]; then
bgnotify "#win (took $elapsed)" "$cmd"
if [[ $1 -eq 0 ]]; then
bgnotify "#win (took $elapsed)" "$2"
else
bgnotify "#fail (took $elapsed)" "$cmd"
bgnotify "#fail (took $elapsed)" "$2"
fi
}
@ -63,10 +63,10 @@ function bgnotify_appid {
if (( ${+commands[osascript]} )); then
# output is "app ID, window ID" (com.googlecode.iterm2, 116)
osascript -e 'tell application (path to frontmost application as text) to get the {id, id of front window}' 2>/dev/null
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )) && (( ${+commands[jq]} )); then # wayland+sway
elif [[ -n $WAYLAND_DISPLAY && ${+commands[swaymsg]} && ${+commands[jq]} ]]; then # wayland+sway
# output is "app_id, container id" (Alacritty, 1694)
swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | {app_id, id} | join(", ")'
elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then
elif [[ -n $DISPLAY && ${+commands[xprop]} ]]; then
xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5
else
echo $EPOCHSECONDS
@ -76,7 +76,6 @@ function bgnotify_appid {
function bgnotify {
local title="$1"
local message="$2"
local icon="$3"
if (( ${+commands[terminal-notifier]} )); then # macOS
local term_id="${bgnotify_termid%%,*}" # remove window id
if [[ -z "$term_id" ]]; then
@ -86,15 +85,23 @@ function bgnotify {
esac
fi
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id" -sender "$term_id"} &>/dev/null
if [[ -z "$term_id" ]]; then
terminal-notifier -message "$message" -title "$title" &>/dev/null
else
terminal-notifier -message "$message" -title "$title" -activate "$term_id" -sender "$term_id" &>/dev/null
fi
elif (( ${+commands[growlnotify]} )); then # macOS growl
growlnotify -m "$title" "$message"
elif (( ${+commands[notify-send]} )); then
notify-send "$title" "$message" ${=icon:+--icon "$icon"}
if [[ -n $ALACRITTY_WINDOW_ID ]]; then
notify-send -i Alacritty "$title" "$message"
else
notify-send "$title" "$message"
fi
elif (( ${+commands[kdialog]} )); then # KDE
kdialog --title "$title" --passivepopup "$message" 5
elif (( ${+commands[notifu]} )); then # cygwin
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"}
notifu /m "$message" /p "$title"
fi
}

View File

@ -68,14 +68,14 @@ function per-directory-history-toggle-history() {
if [[ $_per_directory_history_is_global == true ]]; then
_per-directory-history-set-directory-history
_per_directory_history_is_global=false
zle -I
echo "using local history"
print -n "\nusing local history"
else
_per-directory-history-set-global-history
_per_directory_history_is_global=true
zle -I
echo "using global history"
print -n "\nusing global history"
fi
zle .push-line
zle .accept-line
}
autoload per-directory-history-toggle-history