forked from elnappo/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra.shell
69 lines (61 loc) · 2.04 KB
/
extra.shell
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
#! /bin/zsh
kill_app_by_port() {
if [[ $1 -eq 0 ]] ; then
echo 'You must specify the port -ex kill_app_by_port 3000'
return 0
fi
echo 'Killing ' $1
lsof -n -a -i TCP:$1 -sTCP:LISTEN -t | xargs kill
}
# deletes a branch from both the local repo and the specified remote
git_delete_branch() {
if [[ $1 == 0 ]] || [[ $2 == 0 ]] ; then
echo 'You must specify the branch and the remote you wish to delete it from ie origin branch_name'
return 0
else
cd `pwd` && git branch -D $2 && git push $1 :$2
fi;
}
# prunes the branches deleted on the remote and then cleans up local branches associated with those pruned branches
git_prune_local() {
if [ -d .git ]; then
vared -p "This will delete all local branches where the remote has been removed are you sure you want to continue (y/n)" -c CONT
if [[ "$CONT" == "y" ]]; then
git fetch -p && for branch in `git branch -vv | grep ': gone]' | gawk '{print $1}'`; do git branch -D $branch; done
git remote | xargs git remote prune
fi;
else
echo 'This is not a git repository'
fi;
}
nvmit() {
if [ -f './.nvmrc' ]; then
nvm install
else
packageJson='./package.json'
if [ -f $packageJson ]; then
result=$(jq --raw-output '.engines.node' $packageJson)
if [ ! -z "$result" ]; then
nvm install $result
else
echo "no engines.node section found in package.json"
nvm use default
fi
else
echo "no package.json found"
nvm use default
fi
fi
}
vv() {
# Assumes all configs exist in directories named ~/.config/nvim-*
local config=$(fd --max-depth 1 --glob 'nvim-*' ~/.config | fzf --prompt="Neovim Configs > " --height=~50% --layout=reverse --border --exit-0)
# If I exit fzf without selecting a config, don't open Neovim
[[ -z $config ]] && echo "No config selected" && return
# Open Neovim with the selected config
NVIM_APPNAME=$(basename $config) nvim $@
}
# sudo() {
# PW=$(bw get password glgdomain)
# echo $PW | command sudo -S $@
# }