Add a "w" alias for watch.
This commit is contained in:
parent
1d97921e7b
commit
55fec03445
40
ansible/roles/base/files/watch_freebsd
Normal file
40
ansible/roles/base/files/watch_freebsd
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Imitate watch from linux
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
############## Setup #########################
|
||||||
|
|
||||||
|
function cleanup {
|
||||||
|
switch_to_main_screen
|
||||||
|
}
|
||||||
|
for sig in EXIT INT QUIT HUP TERM; do
|
||||||
|
trap "set +e; cleanup; exit" "$sig"
|
||||||
|
done
|
||||||
|
|
||||||
|
############## Program #########################
|
||||||
|
|
||||||
|
function main {
|
||||||
|
switch_to_alt_screen
|
||||||
|
while true; do
|
||||||
|
local output=$("$@")
|
||||||
|
clear
|
||||||
|
cat <<<"$output"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function switch_to_alt_screen {
|
||||||
|
# tput smcup
|
||||||
|
echo -e "\e[?1049h"
|
||||||
|
clear
|
||||||
|
}
|
||||||
|
|
||||||
|
function switch_to_main_screen {
|
||||||
|
# tput rmcup
|
||||||
|
echo -e "\e[?1049l"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
8
ansible/roles/base/files/watch_linux
Normal file
8
ansible/roles/base/files/watch_linux
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Invoke watch
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
exec watch "$@"
|
@ -94,6 +94,8 @@
|
|||||||
loop:
|
loop:
|
||||||
- src: bemount.bash
|
- src: bemount.bash
|
||||||
dest: /usr/local/bin/bemount
|
dest: /usr/local/bin/bemount
|
||||||
|
- src: watch_freebsd
|
||||||
|
dest: /usr/local/bin/ww
|
||||||
|
|
||||||
- name: Install rc script
|
- name: Install rc script
|
||||||
copy:
|
copy:
|
||||||
@ -121,4 +123,3 @@
|
|||||||
group: wheel
|
group: wheel
|
||||||
loop:
|
loop:
|
||||||
- disk_labels
|
- disk_labels
|
||||||
|
|
||||||
|
@ -37,3 +37,5 @@
|
|||||||
loop:
|
loop:
|
||||||
- src: mount_disk_image
|
- src: mount_disk_image
|
||||||
dest: /usr/local/bin/mount_disk_image
|
dest: /usr/local/bin/mount_disk_image
|
||||||
|
- src: watch_linux
|
||||||
|
dest: /usr/local/bin/ww
|
||||||
|
Loading…
Reference in New Issue
Block a user