-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliases
133 lines (103 loc) · 3.68 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
alias ".."="source ~/.zshrc"
# COLORS and other defaults
alias ls="ls --color --group-directories-first -F"
alias grep="grep --color"
alias ip="ip -color"
# Unix
fun_dirs(){
if [ -z $1 ]; then
PLACE='.'
else
PLACE=$1
fi
ls -1 $PLACE | grep "\/$" | rev | cut -c 2- | rev
}
alias dirs=fun_dirs
alias files="ls | grep -v /"
alias path='echo $PATH | tr -s ":" "\n"'
alias l='ls -1'
alias la='ls -1 -A'
alias ll="ls -l -A"
# Be cautious with moving, copying, linking and removing files.
# Also be verbose
alias ln="ln -iv"
alias rm="rm -Iv"
alias cp="cp -iv"
# Be verbose
alias mkdir="mkdir -vp"
alias rmdir="rmdir -v"
# Program aliases
alias v="$VISUAL"
alias vi="v"
alias e="$EDITOR"
alias gopen='gnome-open'
alias open="xdg-open"
# Git
alias gs="git fuzzy status"
alias dh='git diff HEAD'
alias s='git status -s'
alias staged='git diff --staged'
alias unstaged='git diff'
alias u='git add -u'
# Theme
alias night='sh ~/Share/base16-shell/scripts/base16-tomorrow-night.sh'
alias day='sh ~/Share/base16-shell/scripts/base16-atelier-forest-light.sh'
# Bundler
alias b="bundle"
# Rails
alias migrate="rake db:migrate db:rollback && rake db:migrate db:test:prepare"
# RSpec
# Requires config.example_status_persistence_file_path to be set.
alias f='rspec --only-failures'
alias n='rspec --next'
alias rr='DISABLE_PRY=true rspec'
alias ff='DISABLE_PRY=true rspec --only-failures'
alias nn='DISABLE_PRY=true rspec --next'
alias rdc='run_specs_diffrent_in_this_commit'
alias rdb='run_specs_diffrent_on_this_branch'
alias files_different_on_this_branch='git diff --diff-filter=AM --name-status master..HEAD | grep .rb | cut -c 3- | paste -sd " "'
alias files_different_in_this_commit='git diff --diff-filter=AM --name-status HEAD | grep .rb | cut -c 3- | paste -sd " "'
alias spec_files_different_on_this_branch='git diff --diff-filter=AM --name-status master..HEAD | grep _spec.rb | cut -c 3- | paste -sd " "'
alias spec_files_different_in_this_commit='git diff --diff-filter=AM --name-status HEAD | grep _spec.rb | cut -c 3- | paste -sd " "'
alias run_specs_diffrent_in_this_commit='bundle exec rspec $(spec_files_different_in_this_commit)'
alias run_specs_diffrent_on_this_branch='bundle exec rspec $(spec_files_different_on_this_branch)'
alias lint_files_different_in_this_commit='bundle exec rubocop $(files_different_in_this_commit)'
alias lint_spec_files_different_in_this_commit='bundle exec rubocop $(spec_files_different_in_this_commit)'
#FZF Magic
alias aptinfo='apt list --installed | fzf | cut -d'/' -f1 | xargs apt show'
alias br='git branch | grep -v '^\*' | fzf --reverse --height=40% | xargs git checkout'
alias tldrs='tldr -l | tr -s ", " "\n" | fzf --reverse --preview="tldr {}" --preview-window 70%'
function aptexplore(){
apt search $1 2> /dev/null | \
grep -v -e "^ " | \
grep -v -e "^$" | \
cut -d"/" -f1 | \
fzf --reverse --preview="apt show 2> /dev/null {}" --preview-window=60%
}
function manexplore(){
apropos $1 | fzf --reverse +s | cut -d' ' -f1 | xargs man
}
function create_aptfile(){
grep "^sudo.*apt.* install" ~/.zhistory \
| sed -E "s/.*sudo apt.* install//" \
| sed -E "s/--.* //" \
| tr " " "\n" \
| grep -v -e "^$" \
| sort \
| uniq \
| comm -13 ~/dotfiles/Aptfile - \
> ~/dotfiles/Aptfile.tmp
}
function tspasswords() {
TS_PASSWORD_SCRIPT="$HOME/Config/tspassword.sh"
if [ -f $TS_PASSWORD_SCRIPT ]; then
$TS_PASSWORD_SCRIPT $1
else
echo 'Can not find snippet' 1>&2
return 1
fi
}
alias tspw=tspasswords
alias ticket-numbers='git log --oneline production..staging | grep -Eo "\s#[0-9]+" | sort | uniq'
alias tickets='git log --oneline production..staging'
alias k9s="docker run --rm -it -v ~/.kube/config:/root/.kube/config quay.io/derailed/k9s"