about summary refs log tree commit diff stats
path: root/.config/bash/functions
blob: c2bfff2a0b999ff689f97763122f63ea6f7c88d5 (plain) (blame)
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
# vim: ft=sh

pf() {
    # project finder
    root_dir="$HOME/docs/src"
    selected_dir=$(find "$root_dir" -maxdepth 1 -type d | sed "s:$root_dir::;s:/::;/^$/ d" | BEMENU_BACKEND=curses bemenu -p "Choose directory") && cd "$root_dir"/"$selected_dir" || return
}

xb() {
    # function for handling xbps in a nicer way
    case $1 in
        install | i)
            sudo xbps-install "${@:2}"
            ;;
        remove | r)
            sudo xbps-remove -R "${@:2}"
            ;;
        query | q)
            xbps-query "${@:2}"
            ;;
        search | s)
            xbps-query -Rs "${@:2}"
            ;;
        upgrade | u)
            sudo xbps-install -Su
            ;;
        locate | l)
            xlocate "${@:2}"
            ;;
        *)
            printf "Usage:\n"
            printf "xb i: xbps-install\n"
            printf "xb r: xbps-remove -R\n"
            printf "xb q: xbps-query\n"
            printf "xb s: xbps-query -Rs\n"
            printf "xb u: xbps-install -Su\n"
            printf "xb l: xlocate\n"
            ;;
    esac
}

p() {
    # function for handling pacman in a nicer way too
    case $1 in
        install | i)
            sudo pacman -S "${@:2}"
            ;;
        remove | r)
            sudo pacman -Rns "${@:2}"
            ;;
        query | q)
            pacman -Q "${@:2}"
            ;;
        search | s)
            pacman -Ss "${@:2}"
            ;;
        upgrade | u)
            sudo pacman -Syu
            ;;
        locate | l)
            pacman -F "${@:2}"
            ;;
        *)
            printf "Usage:\n"
            printf "p i: pacman -S\n"
            printf "p r: pacman -Rns\n"
            printf "p q: pacman -Qs\n"
            printf "p s: pacman -Ss\n"
            printf "p u: pacman -Syu\n"
            printf "p l: pacman -F\n"
            ;;
    esac
}

ap() {
    # function to make aurutils a bit more friendly
    case $1 in
	i)
	    aur sync ${@:2}
	    sudo pacman -S ${@:2}
	    ;;
	u)
	    aur sync -u
	    sudo pacman -Syu
	    ;;
        *)
            printf "Usage:\n"
            printf "ap i: aur sync && pacman -S\n"
            printf "ap u: aur sync -u && pacman -Syu\n"
	    ;;
    esac
}