summaryrefslogtreecommitdiff
path: root/.zsh/zshfunctions
blob: ad50ea1e219a28d9fa98fc17fb5c5fc4aab91ec2 (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
# Nice mappings to restart/... the services
Start Stop Reload Restart ()
{
    local SUDO

    [[ $UID != 0 ]] && SUDO="sudo"
    $SUDO /etc/init.d/$1 ${0:l}
}

# Quick find
f() 
{
    echo "find . -iname \"*$1*\""
    find . -iname "*$1*"
}

# Change to the directory of a specific package
_cdu ()
{
    cd ${1:h}
}

# unpacks a specific package
_unpack ()
{
    ebuild $1 clean unpack
}

check_libs()
{
    for i in $(ps -A -o pid | tail -n +2); do
        pmap $i | grep deleted && echo $(ps $i)
    done
}

menc()
{
    local p

    read -rs "p?Password: "
    echo

    echo "Loading ~/schreiben/"
    echo $p | encfs --stdinpass ~/.enc/schreiben/ ~/schreiben/

    unset p
}

# list the current enabled gcc flags
# based on a script by mv
list_cc_flags()
{
    local funcname=${0##*/}

    _Usage_$0 ()
    {
        printf '%s\n' "Usage: $funcname c|o [gcc-Flags e.g. -march=native -O2]
        Show which compile|optimization flags are selected when you chose gcc-Flags"
        return ${1:-1}
    }

    case "${1}" in
        c)
            shift
            gcc -v -c -Q "${@}" -o /dev/null -x c - 2>&1 <<PROG
int main(){return 0;}
PROG
            ;;
        o)
            shift
            gcc -c -Q "${@}" -o /dev/null --help=optimizer 2>&1;;
        *)  _Usage_$0;;
    esac
}

# set job count to 1 if there is only one package to install
emerge()
{
    if [[ $# < 3 ]]; then
        command emerge --jobs=1 $@
    else
        command emerge $@
    fi
}