-
Notifications
You must be signed in to change notification settings - Fork 494
/
50_misc.sh
54 lines (46 loc) · 1.31 KB
/
50_misc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
# Check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
alias grep='grep --color=auto'
# Prevent less from clearing the screen while still showing colors.
export LESS=-XR
# Set the terminal's title bar.
function titlebar() {
echo -n $'\e]0;'"$*"$'\a'
}
# SSH auto-completion based on entries in known_hosts.
if [[ -e ~/.ssh/known_hosts ]]; then
complete -o default -W "$(cat ~/.ssh/known_hosts | sed 's/[, ].*//' | sort | uniq | grep -v '[0-9]')" ssh scp sftp
fi
# Disable ansible cows }:]
export ANSIBLE_NOCOWS=1
# "fuck"
if [[ "$(which thefuck)" ]]; then
eval $(thefuck --alias)
fi
# Run a command repeatedly in a loop, with a delay (defaults to 1 sec).
# Usage:
# loop [delay] single_command [args]
# loopc [delay] 'command1 [args]; command2 [args]; ...'
# Note, these do the same thing:
# loop 5 bash -c 'echo foo; echo bar;
# loopc 5 'echo foo; echo bar'
function loopc() { loop "$@"; }
function loop() {
local caller=$(caller 0 | awk '{print $2}')
local delay=1
if [[ $1 =~ ^[0-9]*(\.[0-9]+)?$ ]]; then
delay=$1
shift
fi
while true; do
if [[ "$caller" == "loopc" ]]; then
bash -c "$@"
else
"$@"
fi
sleep $delay
done
}