forked from noctuid/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ranger_functions
69 lines (64 loc) · 1.72 KB
/
ranger_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
58
59
60
61
62
63
64
65
66
67
68
69
# from: https://github.com/z1lt0id/awesome/blob/master/.bashrc
# sanitize - set file/directory owner and permissions to normal values (644/755)
# recursive
# Usage: sanitize <file>
sanitize() {
sudo chmod -R u=rwX,go=rX "$@"
sudo chown -R "$USER".users "$@"
}
make_thumbnail() {
# http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
filename=$1
extension="${filename##*.}"
filename_stripped="${filename%.*}"
convert "$filename" -resize 100x100 "$filename_stripped"_resized."$extension"
}
imp() {
# using imgur-cli (imgur-cli-svn in the aur)
anon=false
# upload with title and caption and copy original url to clipboard
# not really sure what the point of name is in addition to title
title="random"
# description
caption="none"
# name=$title
# file should be the last argument
filename=${!#}
while getopts t:c:a opt
do
case $opt in
t) title=$OPTARG;;
c) caption=$OPTARG;;
# n) name=$OPTARG;;
a) anon=true;;
*) return 1;;
esac
done
if $anon; then
# send info to file (e.g. in case want delete url or imgur page as well)
imgur upload $filename > ${filename%.*}.txt
awk '/original/ {print $2}' ${filename%.*}.txt \
| xclip -selection clipboard
else
# using xclip; xsel doesn't work consistently for some reason
imgur --user=angelicsedition --ask-pass upload -t "$title" \
-c "$caption" "$filename" | awk '/original/ {print $2}' \
| xclip -selection clipboard
fi
}
# extract archive then delete it
exd() {
atool -x "$1" && rm "$1"
}
trash-ignore-empty() {
if [[ -z $1 ]]; then
return 1
fi
# trash-cli's "trash-put -- -foo" will error that -- does not exist
# fixed on master though
trash-put "$@"
}
# vim: ft=sh:
# Local Variables:
# mode: sh
# End: