-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_aliases
133 lines (106 loc) · 2.95 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
# Used to launch steam on Linux.
function steamgo {
LD_PRELOAD='/usr/$LIB/libstdc++.so.6' steam
}
# Used to transfer files to transfer.sh
transfer() {
if [ $# -eq 0 ]; then
echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md";
return 1;
fi
tmpfile=$( mktemp -t transferXXX );
if tty -s; then
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile;
else
curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ;
fi;
cat $tmpfile;
rm -f $tmpfile;
}
# Create Python virtualenv
alias mkvenv='virtualenv -p python3 env'
# Activate virutal environment
function venv() {
source env/bin/activate
}
# Week of year
alias week='date +%W'
function apt-installed() {
(zcat $(ls -tr /var/log/apt/history.log*.gz); cat /var/log/apt/history.log) 2>/dev/null | \
egrep '^(Start-Date:|Commandline:)' | \
grep -v aptdaemon | \
egrep '^Commandline:'
}
function github-create-repo() {
echo Creating github repo $1
curl -u 'treadup' https://api.github.com/user/repos -d '{"name":"'$1'"}'
}
# Lockscreen for OSX.
function lockscreen {
echo "Ctrl-Cmd-Q to lock the screen"
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
}
# Grep notes folder recursively
function notesgrep() {
grep -r --exclude-dir=".git/" $1 ~/notes
}
# Touch all files in the given folder.
function touchall() {
find $1 -exec touch {} \;
}
# On OSX add ability to launch Google Chrome, Firefox and Safari from the command line.
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX specific configuration
function firefox() {
open -a Firefox $@
}
function google-chrome() {
open -a "Google Chrome" $@
}
function safari() {
open -a Safari $@
}
fi
# Connects to the running Emacs server.
# Creates a new graphical frame.
function em() {
emacsclient -a '' $@
}
# Connects to the running Emacs server.
# Creates a new graphical frame.
function emc() {
emacsclient -a '' -c $@
}
# Connects to the running Emacs server.
# Creates a new client frame on the current text terminal.
function emt() {
emacsclient -a '' -t $@
}
function automute() {
case $1 in
"on" )
amixer -c 0 sset 'Auto-Mute Mode' Enabled ;;
"off" )
amixer -c 0 sset 'Auto-Mute Mode' Disabled ;;
"show" )
amixer -c 0 sget 'Auto-Mute Mode' ;;
esac
}
function web() {
http --follow $1 | html2text | less
}
# Django
alias djr='python manage.py runserver'
alias djm='python manage.py migrate'
alias djmm='python manage.py makemigrations'
alias djs='python manage.py shell'
# Anaconda
function acp() {
export PATH=$HOME/anaconda3/bin:$PATH
}
# tmuxp
alias tmuxp='pew in tmuxp tmuxp'
if [[ "$OSTYPE" == "linux-gnu" ]]; then
alias open='xdg-open';
fi