summaryrefslogtreecommitdiff
path: root/.config/broot/launcher/bash/br
blob: f8dbe932b0841946c00fdcb1ebc99b03d2e3a83b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# This script was automatically generated by the broot program
# More information can be found in https://github.com/Canop/broot
# This function starts broot and executes the command
# it produces, if any.
# It's needed because some shell commands, like `cd`,
# have no useful effect if executed in a subshell.
function br {
    local cmd cmd_file code
    cmd_file=$(mktemp)
    if broot --listen broot --outcmd "$cmd_file" "$@"; then
        cmd=$(<"$cmd_file")
        command rm -f "$cmd_file"
        eval "$cmd"
        if [ "$KAKOUNE_SESSION" ]
        then echo "$cmd" | kak -p "$KAKOUNE_SESSION"
        fi
    else
        code=$?
        command rm -f "$cmd_file"
        return "$code"
    fi
}