-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions
51 lines (44 loc) · 1.07 KB
/
functions
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
# g acts as 'git status' or as git
# Source: https://github.com/thoughtbot/dotfiles
g() {
if [[ $# > 0 ]]; then
git $@
else
git status --short --branch # Needs whitespace or comment at the end (Strange behaviour)
fi
}
touch() {
if [ "$#" = 1 ]; then
DIRNAME=$(dirname $1)
mkdir -p $DIRNAME
command touch $1
else
command touch "$@"
fi
}
aws_profile() {
if [ "$1" = "--unset" ] || [ "$1" = "" ]; then
unset AWS_PROFILE
unset AWS_DEFAULT_PROFILE
echo > ~/.aws/profile
else
echo "export AWS_PROFILE=$1" > ~/.aws/profile
echo "export AWS_DEFAULT_PROFILE=$1" >> ~/.aws/profile
source ~/.aws/profile
fi
}
aws_profiles() {
grep -ho '[^ ]*\]' ~/.aws/credentials ~/.aws/config | tr -d '\[\]\\' | sort
}
copy() {
unameOut="$(uname -s)"
case "${unameOut}" in
Darwin*) COPY_PROGRAM="pbcopy";;
*) COPY_PROGRAM="xsel -b"
esac
if [ $# -eq 0 ]; then
$COPY_PROGRAM
else
cat "$1" | $COPY_PROGRAM
fi
}