-
Notifications
You must be signed in to change notification settings - Fork 1
/
min.sh
63 lines (60 loc) · 1.08 KB
/
min.sh
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
#!/bin/bash
#
# Minimal configuration that I prefer when using remote machines.
#
# Evaluate with:
# . <(curl https://raw.github.com/philz/snippets/master/min.sh)
set -o vi
alias vi=vim
PS1='[$?][\u@\h \W]\$'
function absolute {
ruby -r pathname -e 'puts "#{Pathname.new(ARGV[0]).realpath}\n"' $*
# Or I could do...
# perl -MCwd -e 'print Cwd::abs_path(shift), "\n"' ~/cdpat
}
function cdg () {
DIR=$(git rev-parse --show-cdup);
if [ $? -eq 0 ]; then
if [ ! -z $DIR ]; then
cd $DIR;
fi;
fi
}
ff ()
{
find . -name "$1"
}
fvi ()
{
vi $(find . -name "*$1*")
}
gcp ()
{
for x in $*;
do
git cherry-pick -x $x;
done
}
git-new-branch ()
{
echo git checkout -b $1 $2;
git checkout -b $1 $2
}
notify ()
{
"$@";
if [[ $? -eq 0 ]]; then
notify-send Success "$*";
else
notify-send Failure "$*";
fi
}
parse_git_branch ()
{
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo ${ref#refs/heads/}
}
unixtime ()
{
gawk "BEGIN { print strftime("'"'"%c"'"'", $1); }"
}