~tommoa/dots

ref: 856b7ced187ec1b1500f64bde2d695bfb68546c0 dots/.config/ion/initrc -rw-r--r-- 5.1 KiB
856b7cedTom Almeida waybar: Change default music symbol to  3 months ago
                                                                                
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
if not test -d $HOME/.config/ion/plugins
    # We don't have plugins, so clone them in first.
    git clone https://gitlab.redox-os.org/redox-os/ion-plugins $HOME/.config/ion/plugins
end

source ~/.config/ion/plugins/init.ion
source ~/.config/ion/plugins/tools/gpg-agent.ion

export SKIM_DEFAULT_OPTIONS="--multi --ansi --bind=ctrl-e:up --preview='bat --plain --color=always {}'"

if not exists -s SSH_CLIENT
    # Only launch TMUX if we're not in an SSH session
    if not exists -s VIMRUNTIME
        # We're not in a VIM session
        if not exists -s TMUX
            # We're not already in a TMUX session
            let tmux = $(/usr/bin/env which tmux)
            let sessions: int = $len(@lines($($tmux list-sessions)))
            if test $sessions -gt 0
                exec $tmux attach
            else
                exec $tmux new-session
            end
        end
    end
end

fn PROMPT
    fn ssh_prompt
        if exists -s SSH_CLIENT
            # We're in an SSH session.
            printf "${c::red}\@${c::black}${HOST}"
        end
    end
    fn kube_prompt
        if exists -b kubectl
            # We have kubectl.
            let context = $(kubectl config current-context)
            if not eq $len(context) 0
                # Icons:
                # \u2388: ⎈
                # \u2638: ☸
                printf "${c::default,bold}{${c::light_red}☸${c::default}:${c::blue}${context}${c::default}}${c::reset} "
            end
        end
    end
    fn git_prompt
        if exists -s GIT_PROMPT && test $GIT_PROMPT -eq 1 && git rev-parse --is-inside-work-tree -q &> /dev/null
            let num_added: int = 0;
            let num_removed: int = 0;
            for line in @lines($(git diff-files --numstat -r))
                let new_added = $(echo $line | cut -f1)
                let new_removed = $(echo $line | cut -f2)
                let num_added = $((num_added+new_added))
                let num_removed = $((num_removed+new_removed))
            end
            let totals = "";
            if test $num_added -gt 0 || test $num_removed -gt 0
                let totals = ":"
                if test $num_added -gt 0
                    let totals = "$totals${c::0x55}+$num_added"
                end
                if test $num_removed -gt 0
                    let totals = "$totals${c::light_red}-$num_removed"
                end
            end
            printf "[${c::red,bold}$(git symbolic-ref --short -q HEAD || git rev-parse --short HEAD)${c::default}$totals${c::default}] "
        end
    end
    fn venv
        if exists -s VIRTUAL_ENV
            let env = $(echo $VIRTUAL_ENV | awk -F'/' '{printf $NF}')
            printf "${c::bold}(${c::yellow}$env${c::default,bold})${c::default} "
        end
    end
    printf "$(kube_prompt)${c::0x55,bold}${USER}$(ssh_prompt)${c::default}:${c::0x4B}${SWD}${c::default}# $(venv)$(git_prompt)${c::reset}"
    drop kube_prompt
    drop ssh_prompt
end

fn kctx context:str -- Set the kubernetes context
    kubectl config use-context $context
end

fn show what:str -- Show the existing setting for a variable
    match @split(what)[0]
        case "kctx"
            kubectl config get-contexts
        case _
            echo "[${color::red}@split(what)[0]${color::reset}] does not seem to exist"
            echo "options:${color::blue}"
            echo -e "\tkctx"
            printf "${color::reset}"
    end
end

fn no what:str -- Remove an existing setting for a variable
    match @split(what)[0]
        case "kctx"
            kubectl config unset current-context
        case _
            echo "[${color::red}@split(what)[0]${color::reset}] does not seem to exist"
            echo "options:${color::blue}"
            echo -e "\tkctx"
            printf "${color::reset}"
    end
end

fn mux session:str -- Move or create a tmux session
    let tmux = $(/usr/bin/env which tmux)
    let fd = $(/usr/bin/env which fd || /usr/bin/env which fdfind)
    let dir = $($fd --no-ignore -i -td "$session" ~/Documents | awk -F'/' 'NR==1{n=NF; m=$0} NF<n{ m=$0; n=NF } END { print m }')
    $tmux if-shell                      \
        "$tmux has-session -t $session" \
        "switch-client -t $session"     \
        "new-session -ds $session -c $dir; switch-client -t $session"
end

alias tls="tmux ls"

fn del session:str -- Delete a tmux session
    let tmux = $(/usr/bin/env which tmux)
    $tmux kill-session -t $session
end

fn update_rust -- Update a rust crate
    let gitdr = $(git fetch --dry-run &| wc -l)
    let gitdr:int = $((gitdr))
    if test $(echo $gitdr) -ne 0
        echo "${c::red}Updating${c::reset}"
        git checkout .
        git pull --recurse-submodules
        cargo install --path . --force
    else
        echo "${c::green}Already updated!${c::reset}"
    end
end

if matches $(uname) "Darwin"
    # We're on OSX
    # We need to set PATH here because if we try to set it later, we will error
    # on all things installed by homebrew.
    # Set path to use homebrew's less
    # export PATH=$PATH
    export PAGER=less
end

export EDITOR=$(which nvim)
export GIT_PROMPT=1
export LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

source ~/.cargo/env