-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaliases
206 lines (189 loc) · 5.66 KB
/
aliases
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
### NOTE ###
# Do not add more aliases to this file
# The way I handle aliases now is by creating a dedicated file for each set of aliases
# Check the folder chezmoi/dot_config/aliases
alias reload='source ~/.bashrc'
alias please='__executeLastCommandAsSuperUser'
alias dotvim='(cd ~/.dotfiles && vim nvim/init.vim)'
alias zvim='(cd ~/.dotfiles && vim zsh/zshrc)'
# ---- Docker aliases
alias drun='docker run -it --rm -e NPM_TOKEN=${NPM_TOKEN}'
alias drunvol='docker run -it --rm -v $PWD:/home -e NPM_TOKEN=${NPM_TOKEN}'
alias dex='docker exec -it '
alias cordova='drun --privileged -v /dev/bus/usb:/dev/bus/usb -v $PWD:/src --name cordova beevelop/cordova'
alias dimg='docker images'
alias dimgs='dimg | sort -n -k 7' # sort by size
alias dimgst='dimg | head -1 && dimg | sort -r -k 1' # sort by title
alias drim='docker rmi'
alias dps='docker ps --format "table {{.Names}}\t\t{{.Image}}"'
alias docker-ps='docker ps --format "{{.Image}} \t\t {{.Names}}"'
alias dpsa='docker ps -a --format "table {{.Names}}\t\t{{.Image}}"'
alias docker-cleanup='docker ps -a | grep Exit | grep months | cut -d " " -f 1 | xargs docker rm'
alias dm='docker-machine'
alias dc='docker-compose'
alias dctail='docker-compose logs -f --tail=50'
alias dcreset='docker-compose stop && docker-compose rm -f'
dimg-repofilter(){
docker images --format "{{.Repository}} {{.ID}}" | grep $1
}
# ---- System aliases
alias chx='chmod 755'
alias chr='chmod 644'
alias l='ls -l'
alias ll='ls -la'
alias lsh='ls -lhXG'
alias lr='ls -ltr'
#--------------
# ---- Git ----
#--------------
alias g='git status'
alias ga='git add --all'
alias gb='git branch'
alias gc='git checkout'
alias gcm='git checkout master'
alias gac='ga && gcm'
alias push='git push'
alias pushu='git push -u origin HEAD'
alias gundo='git reset --soft HEAD~1'
alias cdsub='cd $(git submodule --quiet foreach "echo \$path" | fzf)' # cd to git submodule with fzf
function git_grep_file() {
#git_grep_file filename str
git --no-pager grep "$2" $(git rev-list --all -- $1) -- $1
}
function rebaseN(){
noglob git rebase --interactive HEAD~$1
}
#----- Other stuff
alias bashrc='vi ~/.bashrc && refresh'
alias lgrep=' ls -la | grep'
function pushSnippets(){
cd ~/mega/programacion/node/vscodePlugins/vscode-node-snippets/
git add . && git commit -m "Added more stuff" && git push
cd -
}
function fuzzy_cat(){
fd "$1" ../ -x cat {}
}
function fzfkill() {
line=$(ps -ef | fzf -q "$1" -1 --height 40% --layout reverse -d 20)
processnumber=$(echo $line | awk '{print $2}')
if [ -n "$processnumber" ]; then
kill -9 $processnumber
fi
}
alias fkill='fzfkill'
alias fzkill='fzfkill'
# ---- NPM
alias npm-i='npm i --registry=https://registry.npmjs.org/'
alias npr='npm run'
alias npmd='npm i -D'
alias startElastic='docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:5.4.3'
alias milis='echo $(($(date +%s%N)/1000000))'
alias yarnd='yarn add -D'
# Systems
alias who_uses_serial='lsof | grep "/dev/cu"'
port_used(){
lsof -nP -i4TCP:$1
}
alias pport='port_used'
# ---- STUPID
alias oraculo='node bin/oraculo.js'
# ---- WORK related
create_component (){
mkdir $1 && cd $1
touch index.js
echo "import $1 from './$1.component';\n\nexport default $1;" > index.js
for i in styled.js component.jsx variants.js;do
touch "$1.$i"
done
echo "
import styled from '@emotion/styled';
import COLORS from '$shared/variables/colors';
" > $1.styled.js
cd -
}
# ---- QMK
checkout-danielo-ergodox(){
read -r DANIELO_BRANCH
git checkout $DANIELO_BRANCH users/danielo515
git checkout $DANIELO_BRANCH quantum/process_keycode/process_leader.c
git checkout $DANIELO_BRANCH keyboards/ergodox_ez/keymaps/danielo515
}
check_command() {
local command=$1
if command -v "$command" &> /dev/null; then
return 0
else
return 1
fi
}
# --- Better UNIX commands ----------
if check_command exa; then
alias ls='exa'
alias l='exa -la'
fi
alias sloc='scc'
# --- Neovim flavours ----------
chadvim(){
NVIM_APPNAME=nvchad nvim "$@"
}
# previously it was lazyvim,
lzvim(){
NVIM_APPNAME=Lazy nvim "$@"
}
s(){
source "$1"
}
# When you are in a git repository, add the repository you say as remote
# it uses github cli to ask for the url
function ghadd {
git status &> /dev/null
if [ $? -ne 0 ]; then
echo "Not a git repository"
return 1
fi
curdir=$(pwd)
defaultName=$(basename $curdir)
repo=$(gum input --prompt "Repo name: " --value $defaultName)
git remote add origin $(gh repo view $repo --json sshUrl --jq .sshUrl)
}
# adds a github repository as a submodule
function ghsub {
git status &> /dev/null
if [ $? -ne 0 ]; then
echo "Not a git repository"
return 1
fi
repo=$(gum input --prompt "Repo name: ")
git submodule add $(gh repo view $repo --json sshUrl --jq .sshUrl)
}
# create a new repo in github
function ghnew {
repo=$(gum input --prompt "Repo name: ")
gh repo create $repo -l MIT --public
}
# takes a file containing a list of newline separated files and zips them all
function zip_list {
if [ $# -ne 2 ]; then
echo "Usage: zip_list <zipfile> <listfile>"
return 1
fi
zip "$1" -@ < "$2"
}
favs() {
fd . "$(chezmoi source-path)/.." | fzf --preview 'bat --color=always --style=header,grid --line-range :500 {}'
}
rgi() {
rg --no-ignore --hidden "$@"
}
## Add a symlink into chezmoi creating the appropriate template
alias chezmoln='chezmoi add --template-symlinks '
ALIASES_FOLDER="$HOME/.config/aliases"
## If there are files under an alias folder, source all of them that end with _aliases
if [ -d "$ALIASES_FOLDER" ]; then
for file in $ALIASES_FOLDER/*_aliases; do
if [ -f "$file" ]; then
source "$file"
fi
done
fi