migrated more functions

pull/2/head
Hari Sekhon 5 years ago
parent d93a6e0abd
commit 811f0e5ab5

@ -44,6 +44,26 @@ hr(){
echo "# ============================================================================ #"
}
repeat(){
local i n
n="$1"
shift
if [ -z "$n" ]; then
echo "usage: repeat N command args"
return 1
fi
for ((i=1; i <= n; i++)); do
"$@"
done
}
loop(){
while true; do
eval "${*//\$/\\$}"
sleep 1
done
}
topcommands(){
# first awk print $2 but my advanced history records `date '+%F %T'` in between number and command for $2 and $3, making command $4
history |
@ -83,6 +103,12 @@ f(){
eval find -L . -type f "$grep"
}
add_etc_host(){
local host_line="$*"
$sudo grep -q "^$host_line" /etc/hosts ||
$sudo echo "$host_line" >> /etc/hosts
}
vihosts(){
[ $EUID -eq 0 ] && sudo="" || sudo=sudo
$sudo vim /etc/hosts

Loading…
Cancel
Save