-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
executable file
·82 lines (65 loc) · 1.46 KB
/
bashrc
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
#!/bin/bash
sysname=`uname`
if [ "_$sysname" == "_CYGWIN_NT-5.1" ]; then
alias ls='ls -h --color=tty' # classify files in colour
elif [ "_$sysname" == "_Darwin" ]; then
alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
alias Visio='/Applications/Visio.app/Contents/MacOS/Visio'
alias ls='ls -G'
fi
alias hip=`which tail` # answer for https://twitter.com/igaiga555/status/276291925634592768
# make daily tempolary directory
mkdir -p $HOME/tmp/$(date +%Y%m/%d)
function convert-mp3() {
local input=''
local output=''
if [ $# -eq 1 ]; then
local input="$1"
local output="$1.mp3"
elif [ $# -eq 2 ]; then
local input="$1"
local output="$2"
else
echo 'convert-mp3 input [output]'
return 0;
fi
ffmpeg -y -i "$input" -acodec mp3 -ar 44100 -ab 192 "$output"
}
# screen control functions
function is-screen() {
local term=$(echo "$TERMCAP" | head -1 | cut -d "|" -f 1)
if [ "$term" == 'SC' ]; then
echo 'yes'
else
echo 'no'
fi
}
function screen() {
local cmd="$(which screen) $@"
if [ $(is-screen) == 'yes' ]; then
$cmd
else
exec $cmd
fi
}
function exec-on-screen() {
local cmd="$@"
local title="${1##*/}"
if [ $(is-screen) == 'yes' ]; then
$(which screen) -t "$title" $cmd
else
$cmd
fi
}
function vi() {
exec-on-screen $(which vi) $@
}
function vim() {
exec-on-screen $(which vim) $@
}
function vimdiff() {
exec-on-screen $(which vimdiff) $@
}
function ssh() {
exec-on-screen $(which ssh) $@
}