Project

General

Profile

Arvswitch » History » Version 5

Peter Amstutz, 11/16/2015 01:52 PM

1 1 Peter Amstutz
h1. Arvswitch
2
3
Copy this into your @.bashrc@ or create a new file called something like "arvswitch.sh" and add the line ". arvswitch.sh" to your @.bashrc@
4
5
<pre>
6
HISTIGNORE=$HISTIGNORE:'export ARVADOS_API_TOKEN=*'
7
8
arvswitch() {
9
    if [[ -n "$1" ]] ; then
10
        if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
11 3 Peter Amstutz
            unset ARVADOS_API_HOST_INSECURE
12 1 Peter Amstutz
            for a in $(cat $HOME/.config/arvados/$1.conf) ; do export $a ; done
13
        else
14
            echo "$1 unknown"
15
        fi
16
    else
17
        echo "Switch Arvados environment conf"
18
        echo "Usage: arvswitch name"
19
    fi
20
}
21
22
arvlist() {
23
    (cd $HOME/.config/arvados && ls --indicator-style=none *.conf) | rev | cut -c6- | rev
24
}
25
26
arvsave() {
27 2 Peter Amstutz
    if [[ -n "$1" ]] ; then
28 1 Peter Amstutz
        env | grep ARVADOS_ > $HOME/.config/arvados/$1.conf
29 5 Peter Amstutz
        chmod 0600 $HOME/.config/arvados/$1.conf
30 1 Peter Amstutz
    else
31
        echo "Save current Arvados environment variables to conf file"
32
        echo "Usage: arvsave name"
33
    fi
34
}
35
36
arvrm() {
37
    if [[ -n "$1" ]] ; then
38
        if [[ -f $HOME/.config/arvados/$1.conf ]] ; then
39
            rm $HOME/.config/arvados/$1.conf
40
        else
41
            echo "$1 unknown"
42
        fi
43
    else
44
        echo "Delete Arvados environment conf"
45
        echo "Usage: arvrm name"
46
    fi
47
}
48
</pre>