-
Notifications
You must be signed in to change notification settings - Fork 1
/
.functions
43 lines (38 loc) · 1014 Bytes
/
.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
# create a new directory and enter it
function cdmkdir () { mkdir -p "$@" && cd "$@" }
# move file/directory to the trash
function trash () {
local trash_dir="${HOME}/.Trash"
local temp_ifs=$IFS
IFS=$'\n'
for item in "$@"
do
if [[ -e "$item" ]]
then
item_name="$(basename $item)"
if [[ -e "${trash_dir}/${item_name}" ]]
then
mv -f "$item" "${trash_dir}/${item_name} $(date "+%H-%M-%S")"
else
mv -f "$item" "${trash_dir}/"
fi
fi
done
IFS=$temp_ifs
}
# git functions
function get_git_branch () {
echo `git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
}
#shortcut to open documentation with dash
function dash() { open dash://"$1" }
# shortcut for code directory
function c () { cd ~/code/$1 }
function _c () { _files -W ~/code -/ }
compdef _c c
# compress video files
compressMp4 () {
for f; do
ffmpeg -y -i "$f" -vcodec h264 -preset ultrafast -pix_fmt yuv420p -movflags faststart "${f%.*}-compressed.mp4"
done
}