summaryrefslogtreecommitdiffstats
path: root/roles/common/files/setfunctions.sh
blob: a0f29b0139a3942baa846a6ad9b23ed0bc43ca7f (plain)
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
function rebours {
    i=$1
    while [[ $i -ge 0 ]]
    do
        echo -e "\r"$i "\c"
        sleep 1
        i=$(expr $i - 1)
    done
    echo ""
}

function xtail {
    if [ "$#" -gt 0 ]
    then
        gnome-terminal -e "tail -n 0 -f $@"
    else
        echo "Input interdit"
    fi
}

# anthologie
function tarls {
    # Détection du type de fichier d'archive

    local filetype        # Sortie de la commande file
    local compresstype    # Premier mot de $tartype
    local tarflags        # Drapeaux d'option pour tar
    local defaultflags    # Drapeaux par défaut

    # on détermine le type de fichier
    filetype=$(file "$1")

    # Récupération par cut du seul premier mot, par exemple "gzip"
    compresstype=$(echo $filetype |cut -d ' ' -f 2)

    case $compresstype in
      gzip)       tarflags=-zvtf;;
      bzip2)      tarflags=-jvtf;;
      XZ)         tarflags=-Jvtf;;
      POSIX)      tarflags=-vtf;;
      lzip)       tarflags=--lzip
                  defaultflags=-vtf;;
      LZMA)       tarflags=--lzma
                  defaultflags=-vtf;;
      "compress'd") tarflags=-Zvtf;;
      *)          echo "Type d'archive inconnu"; return 1;;
    esac;

    tar $tarflags $defaultflags $1
}

function xless {
    if [ "$#" -gt 0 ]
    then
        gnome-terminal -e "less $@"
    else
        echo "Input interdit"
    fi
}

function xcat {
    command=$@
    gnome-terminal -e "$command"
}

function phone2 {
    ssh-agent > /tmp/vars.txt
    . /tmp/vars.txt
    ssh-add ~/.ssh/xcg
}

function phone3 {
    ssh-agent > /tmp/vars.txt
    . /tmp/vars.txt
    ssh-add ~/.ssh/id_rsa
}

function blocnote {
    trsync -aPh casper@falcon:Images/bloc-notes/courant/\* ~/Images/Bloc-notes/
}

function onionlookup {
    SUFFIX=.casperlefantom.net
    while test $# -gt 0
    do
        RESULT=`dig TXT +short $1$SUFFIX`
        if [[ $RESULT != "www.casperlefantom.net." ]]
        then
            echo $RESULT | sed 's/"//g'
        else
            echo "erreur: domaine $1 hors-zone DNS"
        fi
        shift
    done
}