-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashinterfuncs
executable file
·71 lines (62 loc) · 1.61 KB
/
bashinterfuncs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#Bash interactive functions.
# Name me something hidden, like ".bashinterfuncs", and source me from .profile
# Copyright 2019 David C. Todd, License for use: GPL 2.0
wla ()
{
: doc "Add email address to spamassassin white list."
echo whitelist_from $1 >> ~/.spamassassin/user_prefs ;
}
nalias ()
{
: doc "Add an alias to .alias (sourced in .profile), and the current session"
alias $1="$2" && echo "alias $1='$2'" >> ~/.alias
}
#find every file name starting with $1, get the part of its filename
#that starts after the first '.', then change the first part to $2.
# For instance, foo.bar, foo.baz, and foo.bar.baz
# $ ls
# foo.bar foo.baz foo.fum
# $ massmv foo pie
# $ ls
# pie.bar pie.baz pie.fum
massmv ()
{
: doc "Rename files starting matching $1.* to $2 and the suffix from the old file."
if (($# != 2)); then echo "must have two parameters"; return 1; fi
for i in $1.*;
do
suf=`echo $i | cut -d . -f 2-`;
mv $i $2.$suf;
done
}
uz ()
{
: doc "Unzip a file into a (created?) directory called the filename minus .zip"
dir=`basename $1 .zip`;
mkdir $dir;
mv $1 $dir;
cd $dir;
unzip $1;
cd ..;
ls -l $dir
}
les ()
{
: doc "If the argument is a directory list it, otherwise less it."
if (($# == 0)); then ls;
elif /usr/bin/test -d $1; then ls $1;
else less $1;
fi
}
grwl ()
{
: doc "Grep the spamassassin prefs file (which holds the whitelist)"
grep $1 ~/.spamassassin/user_prefs
}
lsfunc ()
{
: doc "List functions with docstrings, if there is a doc"
: doc "If it has more than one line it'll look like this."
declare -f | lsfun.py
}