-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
57 lines (47 loc) · 1.44 KB
/
.functions
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
# cria o diretório e entra nele
mkdircd() {
mkdir "$1"
cd "$1"
}
# transfer.sh function
# envia para o arquivo para o https://transfer.sh/arquivo
# https://github.com/dutchcoders/transfer.sh/
transfer() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile;
echo # added to break line in the end
}
# gera uma senha aleatória
genpasswd() {
local l=$1
[ "$l" == "" ] && l=16
tr -dc 'A-Za-z0-9_\{\}\[\]\(\)\\/^~?!@#$%&*`\-\+=,\ ' < /dev/urandom | head -c ${l} | xargs
}
# atualiza meus principais repositórios ao iniciar
git_update() {
echo "git pull scripts..."
cd scripts
git pull
cd ../dotfiles
echo "git pull dotfiles..."
git pull
cd ~
}
# procura pelo conteúdo de arquivos de uma extensão
#
# uso: grepext <busca> <extensao>
# exemplo: grepex class php
grepext() {
if [ ! $# -eq 2 ]; then
echo "uso: grepext <busca> <extensao>"
return 1;
fi
grep -inE "$1" `find . -name "*.$2"`
}
# codifica string base64
base64encode() {
echo "$1" | base64
}
# decodifica string base64
base64decode() {
echo "$1" | base64 --decode
}