-
Notifications
You must be signed in to change notification settings - Fork 2
/
.functions.zsh
79 lines (64 loc) · 1.74 KB
/
.functions.zsh
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
72
73
74
75
76
77
78
79
get_remote() {
git remote -vv | tail -n1 | awk '{print $2}' | tr -d '\n' | xcopy
}
open_remote() {
open $(git remote -vv | grep origin | tail -n1 | awk '{print $2}' | xargs -I URL sh -c "echo URL | grep https || echo URL | sed 's/:/\//' | sed 's/^.*@/https:\/\//'") 1>/dev/null
}
grab() {
realpath "$1" | tr -d "\n" | xcopy
}
naqui() {
tmux new -s "nautilus@$(basename $(pwd))" -d 'nautilus .'
}
cpp_sources() {
find . -regextype posix-extended -regex \
".*\.(cpp|cxx|cc|hpp|hxx|h)" |
grep -vE "^./(build|3rdparty)/"
}
filename() {
BASENAME="$(basename -- $1)"
FILENAME=${BASENAME%.*}
echo $FILENAME
}
check_includes() {
grep -rhE '^#include\s+(<|").*(>|")' | sort | uniq
}
check_imports() {
grep -rh import | sort | uniq
}
zip_folder() {
folder="$1"
echo "Creating zip file of $folder"
zip -r $folder.zip $folder
}
za() {
zathura --fork $1 2>/dev/null
}
run_docker_cwd() {
docker run --rm -it -u 1000:1000 -v $(realpath .):/workspace -w /workspace $1
}
run_root_docker_cwd() {
docker run --rm -it -v $(realpath .):/workspace -w /workspace $1
}
gitignore() {
curl -sLw n https://www.toptal.com/developers/gitignore/api/$@
}
fast_remove() {
DIR="$(realpath $1)"
printf '%s ' "[WARNING] Removing all contents in \"${DIR}\", are you sure (y/n)"
read REPLY
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
mkdir /tmp/empty_directory
rsync -a --delete /tmp/empty_directory/ ${DIR}/
rm -rf ${DIR}
rm -rf /tmp/empty_directory
echo "Done!"
}
replace_word() {
old_word="$1"
new_word="$2"
grep -rl ${old_word} . | xargs sed -i "s/${old_word}/${new_word}/g"
}
source ~/.local/bin/video_utils