-
Notifications
You must be signed in to change notification settings - Fork 1
/
bashrc.funcs
47 lines (41 loc) · 952 Bytes
/
bashrc.funcs
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
#!/usr/bin/env bash
git_branch(){
git branch 2>/dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/(\1)/"
}
#Generate Mercurial diff and save in `diffs' subdir.
generate_diff(){
name=$1
diff_dir="diffs"
mkdir -p ${diff_dir}
branch=`hg branch`
now=`date +"%F_%T"`
export diff_file_path="${PWD}/${diff_dir}/${branch}_${now}_${name:-diff}.diff"
`hg diff > ${diff_file_path}`
[ $? -eq 0 ] && echo "created diff ${diff_file_path}"
}
check_freq() {
user=$1
hg log --user "${user}" -T "{date|isodate}\n"|cut -d ' ' -f2|cut -d: -f1|sort -n|uniq -c
}
suspendme() {
i3lock -i $HOME/wallpaper/anon.png && sudo pm-suspend
}
mountdev() {
udisksctl mount -b $1
}
genpass()
{
FOR=$1
LEN=$2
shift
if [ "$LEN" == "" ];then
LEN=8
fi
paswd=$(head -c200 /dev/urandom |tr -cd [:alnum:]+[\!\@\#\$]|head -c $LEN)
echo "$paswd"|xclip -selection c
echo "Copied to clipboard"
if [ "$FOR" == "" ];then
FOR=$(date)
fi
echo "${FOR}: $paswd" >> ~/.pass
}