-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
148 lines (117 loc) · 3.96 KB
/
.bash_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
#!/bin/bash
# Configs
alias reload="source ~/.bashrc"
alias bashconfig="nvim ~/.bashrc"
alias sshconfig="nvim ~/.ssh/config"
alias tmuxconfig="nvim ~/.config/tmux/tmux.conf"
# File system
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias ll="ls -lsa"
alias md="mkdir -p"
alias rd="rmdir"
alias rgrep="grep -Hr"
### Git
alias gs="git status"
alias gst="git status"
alias ga="git add"
alias gp="git push"
alias gl="git pull origin"
alias gb="git branch "
alias gc="git commit "
alias gd="git diff"
alias gco="git checkout "
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
alias gsl="git stash list"
alias gsa="git stash apply"
alias gsp="git stash pop"
### NPM
alias nvp="npm version patch"
alias np="npm publish"
### Misc
alias whatsmyip="curl https://ipinfo.io/ip"
alias scanKeys='for key in $HOME/.ssh/*.pub; do ssh-keygen -l -f "${key}"; done | uniq'
alias ffs="sudo !!"
alias ktx=kubectx
alias kns=kubens
alias p=playerctl
alias j=journalctl
alias s=systemctl
if command -v kubectl &> /dev/null
then
alias k='kubectl'; source <(kubectl completion bash); complete -o default -F __start_kubectl k
fi
if command -v git &> /dev/null
then
alias dotf='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'; source /usr/share/bash-completion/completions/git; __git_complete dotf __git_main
alias g='git'; source /usr/share/bash-completion/completions/git; __git_complete g __git_main
fi
if command -v docker &> /dev/null
then
alias d='docker'; source /usr/share/bash-completion/completions/docker; complete -F _docker d
fi
### Specific to MacOS
if [[ `uname` == "Darwin" ]]; then
alias flushDNS="sudo killall -HUP mDNSResponder;sudo kill mDNSResponderHelper;sudo dscacheutil -flushcache"
alias syncTime="sudo sntp -sS time.euro.apple.com"
alias mount_dev="mkdir -p ~/Media/dev.glimworks.se && sshfs -o idmap=user,noapplexattr,auto_cache,reconnect,defer_permissions,noappledouble,volname=dev.glimworks.se dev: ~/Media/dev.glimworks.se/"
alias umount_dev="diskutil umount ~/Media/dev.glimworks.se"
fi
function generateKey {
ssh-keygen -t ed25519 -f ~/.ssh/$1 -P "" -C $2
}
function workspace-upload {
echo "Uploading workspace..."
rsync -raz --exclude=node_modules --exclude=build --exclude=yay --delete --progress /home/robin/Workspace dev:
echo "Done."
}
function workspace-download {
echo "Downloading workspace..."
rsync -raz --exclude=node_modules --exclude=build --exclude=yay --delete --progress dev:Workspace /home/robin
echo "Done."
}
function luks-open {
# Check if required arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 LUKS_FILE MOUNT_POINT"
return
fi
LUKS_FILE="$1"
MOUNT_POINT="$2"
# Get the base name of the LUKS file (excluding the path and extension)
LUKS_BASENAME=$(basename -- "$LUKS_FILE")
MAPPER_NAME="${LUKS_BASENAME%.*}"
# Check if the mount point exists, and create it if not
if [ ! -d "$MOUNT_POINT" ]; then
sudo mkdir -p "$MOUNT_POINT"
fi
# Prompt user for the LUKS passphrase
echo -n "Enter LUKS passphrase for $LUKS_BASENAME: "
read -s passphrase
echo
# Unlock the LUKS container
sudo cryptsetup luksOpen "$LUKS_FILE" "$MAPPER_NAME" <<< "$passphrase"
# Mount the filesystem with full permissions
sudo mount "/dev/mapper/$MAPPER_NAME" "$MOUNT_POINT"
echo "LUKS container ($LUKS_BASENAME) successfully unlocked and mounted at $MOUNT_POINT"
}
function luks-close {
# Check if required argument is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 MOUNT_POINT MAPPER_NAME"
return
fi
MOUNT_POINT="$1"
MAPPER_NAME="$2"
# Check if the specified mount point is currently mounted
if ! mountpoint -q "$MOUNT_POINT"; then
echo "Error: $MOUNT_POINT is not currently mounted."
return
fi
# Unmount the filesystem
sudo umount "$MOUNT_POINT"
# Close the LUKS container
sudo cryptsetup luksClose "$MAPPER_NAME"
echo "LUKS container ($MAPPER_NAME) successfully closed, $MOUNT_POINT unmounted, and device mapper removed."
}