summaryrefslogtreecommitdiff
path: root/fish/conf.d/dotfiles.fish
blob: 70289c71370ea4037971e810553e65caff6b1388 (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
set -gx DOTFILES_DIR ~/git/dotfiles

function dotfiles::update
    set -l prev_pwd (pwd)
    cd $DOTFILES_DIR
    rex home
    cd "$prev_pwd"
end

function dotfiles::update::git
    set -l prev_pwd (pwd)
    cd $DOTFILES_DIR
    git pull
    git commit -a
    git push
    rex home
    cd "$prev_pwd"
end

function dotfiles::fuzzy::edit
    set -l prev_pwd (pwd)
    cd $DOTFILES_DIR
    set -l dotfile (find . -type f -not -path '*/.git/*' | fzf)
    $EDITOR "$dotfile"
    if echo "$dotfile" | grep -F -q .fish
        echo "Sourcing $dotfile"
        source "$dotfile"
    end
    cd "$prev_pwd"
end

function dotfiles::rexify
    cd $DOTFILES_DIR
    rex home
    cd -
end

function dotfiles::random::edit
    $EDITOR (find $DOTFILES_DIR -type f -not -path '*/.git/*' | shuf -n 1)
end

abbr -a .u 'dotfiles::update'
abbr -a .ug 'dotfiles::update::git'
abbr -a .e 'dotfiles::fuzzy::edit'
abbr -a .rex 'dotfiles::rexify'
abbr -a .re 'dotfiles::random::edit'
abbr -a cdconf "cd $HOME/git/conf"
abbr -a cdotfiles "cd $HOME/git/dotfiles"