summaryrefslogtreecommitdiffstats
path: root/common/commandline/fish.fish
blob: 5e5d31e942db5443dbd78e3689f80b48e9b37459 (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
# Disable greeting
set fish_greeting
set -g fish_key_bindings fish_vi_key_bindings
set -g grc_plugin_ignore_execs ls systemctl

bind -M insert \cz 'fg ; commandline -f repaint'

function ssht
    ssh -t "$argv" "tmux new-session -A -s 'ssh-$HOST'"
end

function cdt
    builtin cd (mktemp -d)
    builtin pwd
end

function sll --description "Recursively resolve a symbolic link"
    for path in $argv
        set -l seen_inodes

        while test -L $path
            set inode (stat -c %i $path)

            if contains $inode $seen_inodes
                echo "Infinite recursion detected"
                return 1
            end
            set -a seen_inodes $inode

            ll -d $path || return 1

            set previous_dir (path dirname $path)
            set path (readlink $path | path normalize)
            if not string match -q "/*" $path
                set path (path normalize "$previous_dir/$path")
            end
        end
        ll -d $path || return 1
    end
end

function expand_equal_command
    type -P (string sub --start 2 $argv)
end

abbr -a expand_equal_command --position anywhere --regex "^=.+" --function expand_equal_command