forked from hgmnz/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.aliases
105 lines (92 loc) · 4.04 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
alias unixtime="date +%s"
alias grep="grep -i"
alias which='type -all' # which: Find executables
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias c='clear' # c: Clear terminal display
alias less='less -FSRXc' # Preferred 'less' implementation
alias ls='eza --icons=always --all --tree --level=1 --group-directories-first' # ---- Eza (better ls) -----
alias lsd='eza --icons=always --all --tree --level=1 --only-dirs --group-directories-first'
alias ll='eza --icons=always --all --grid --long --tree --level=1 --group-directories-first' # Preferred 'ls' implementation
alias lld='eza --icons=always --all --grid --long --tree --level=1 --only-dirs --group-directories-first'
alias l="eza --all --grid --header --long --flags --tree --extended --group-directories-first"
alias preview="fzf --preview 'bat --color \"always\" {}'"
alias llrg="fd . --type f | sort -n | tail -1"
alias lsml="fd . --type f | sort -nr | tail -1"
# Navigation
alias ~="cd ~" # ~: Go Home
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias ..='cd ../' # Go back 1 directory level
alias ...='cd ../../' # Go back 2 directory levels
alias .3='cd ../../../' # Go back 3 directory levels
alias .4='cd ../../../../' # Go back 4 directory levels
alias .5='cd ../../../../../' # Go back 5 directory levels
alias .6='cd ../../../../../../' # Go back 6 directory levels
# Helpful additions and overrides
mcd() { mkdir -p "$1" && z "$1"; } # mcd: Makes new Dir and jumps inside
trash() { command mv "$@" ~/.Trash; } # trash: Moves a file to the MacOS trash
ql() { qlmanage -p "$*" >&/dev/null; } # ql: Opens any file in MacOS Quicklook Preview
cd() {
z "$@"
ll
} # Always list directory contents upon 'cd'
pidport() {
lsof -n -i4TCP:$1 | grep LISTEN
}
# AWS Vault
alias ave="aws-vault exec home --"
alias avl="aws-vault login home --duration 12h"
alias avr="aws-vault rotate home --no-session"
# Create Feature Branch
# Arg 1: Branch Name (Required)
cfb() {
if [ -z "$1" ]; then
echo "No branch named specified."
return 1
fi
git checkout master
# Create Release Branch
git pull
git checkout -b release/feature/$1 && git push
# Create Feature Branch
git checkout master
git checkout -b $1
}
# Creates a feature PR for a feature branch
# Arg 1: PR Title (Required)
cpr() {
gh pr create --title $1 --base "release/feature/$(git rev-parse --abbrev-ref HEAD)" --fill --draft
}
# Show all release PRs
srpr() {
gh pr list --base master --label "Type: Release"
}
# Creates a release PR for a feature branch
# Should be executed from a feature branch
# Arg 1: PR Title (Required)
crpr() {
gh pr create --title $1 --base master --head "release/feature/$(git rev-parse --abbrev-ref HEAD)" --label "Type: Release" --fill
}
# Update AWS credentials from vault keychain
# Arg 1: AWS Vault Profile Name (e.g. default or home)
#
# If you are using a newer version of macOS you may need,
# to explicitly add the `aws-vault.keychain` for this to work via KeyChain Access
# https://github.com/99designs/aws-vault/issues/534#issuecomment-596971986
update_credentials() {
if [ -z "$1" ]; then
echo "Missing keychain account, usually the name of your aws-vault profile"
return 1
fi
SECRET=$(security 2>&1 >/dev/null find-generic-password -ga $1)
ACCESS_KEY_ID=$(echo $SECRET | sed -E 's/^password\: "(.*)"$/\1/g' | jq -r '.AccessKeyID')
SECRET_ACCESS_KEY=$(echo $SECRET | sed -E 's/^password\: "(.*)"$/\1/g' | jq -r '.SecretAccessKey')
mv ~/.aws/credentials ~/.aws/credentials.bak
touch ~/.aws/credentials
chmod 600 ~/.aws/credentials
echo "[default]" >~/.aws/credentials
echo "aws_access_key_id=$ACCESS_KEY_ID" >>~/.aws/credentials
echo "aws_secret_access_key=$SECRET_ACCESS_KEY" >>~/.aws/credentials
}
tsh() {
ssh -o RequestTTY=yes "$@" tmux -CC new -A -s tmux-main
}