-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zsh_aliases
114 lines (98 loc) · 2.92 KB
/
.zsh_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
## ls with color
alias ls='ls --color=auto'
## Refresh font cache
alias font-refresh="fc-cache -fv"
## git clone depth 1, who needs to clone full repository if you can clone the top layer only
alias clone="git clone --depth 1"
## merge Xresources, useful for urxvt & rofi theming
alias mergex="xrdb ~/.Xresources"
alias more=less
alias f='fzf --preview "head -100 {}"'
alias clbin="curl -F 'clbin=<-' https://clbin.com"
alias myip='curl http://checkip.amazonaws.com/; curl ipinfo.io'
alias wttr='curl wttr.in/49418'
alias removechars='sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"'
alias darn='sudo $(history -p \!\!)'
alias listgroups='cut -d: -f1 /etc/group'
# Copy ssh key to server
# type "copykey user@server"
function copykey {
[ -z "$1" ] && echo 'Usage: copykey user@server' && return 1
ssh $1 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
}
# ex - archive extractor
# usage: ex <file>
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.tar.xz) tar xpvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# cli-notes
export NOTESDIR="$HOME/Sync/notes"
nn() {
local note_name="$*"
local note_date="`date +%F`"
local note_ext="md"
if [[ $note_name == "" ]]
then
note_name="$note_date.$note_ext"
fi
mkdir -p $NOTESDIR
vim -c 'startinsert' "$NOTESDIR/$note_name"
}
ns() {
local file
[ -z "$1" ] && echo "No argument supplied - Enter a term to search" && return 1
file="$(rg --files-with-matches --no-ignore --ignore-case --hidden --no-heading --no-messages $1 $NOTESDIR | fzf --preview "head -100 {}")"
if [[ -n $file ]]
then
vim $file
fi
}
nl() {
local files
files="$(rg --files $NOTESDIR | fzf --preview "head -100 {}")"
if [[ -n $files ]]; then
vim $files
fi
}
zoteroinstall() {
wget https://raw.github.com/smathot/zotero_installer/master/zotero_installer.sh -O /tmp/zot
tail -n +2 /tmp/zot > /tmp/zotero_installer.sh
chmod +x /tmp/zotero_installer.sh
/tmp/zotero_installer.sh
}
symlink() {
[ -z "$1" ] && echo "No argument supplied - Enter path for Original file and New file" && return 1
ln -sf $1 $2
}
mountmac() {
local macuser="josh"
local macpass="changeme"
local macip="192.168.56.101"
local macshare="Downloads"
local mntpoint="/mnt/mac"
if [ -d $mntpoint ] ; then
sudo mkdir -p $mntpoint
sudo chown -R $USER $mntpoint
fi
sudo mount -t cifs //$macip/$macshare $mntpoint -o username=$macuser,password=$macpass,nounix,sec=ntlmssp,rw,iocharset=utf8,file_mode=0777,dir_mode=0777
cd $mntpoint
}