From b06970472db16bac041dbada87580d759e80e013 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sun, 10 Mar 2024 17:47:43 +0100 Subject: [PATCH] Add `broot` --- config/broot/conf.toml | 56 ++++++++++++++++++++ config/broot/launcher/refused | 4 ++ config/broot/skins/dark.toml | 97 +++++++++++++++++++++++++++++++++++ config/broot/skins/light.toml | 97 +++++++++++++++++++++++++++++++++++ config/broot/verbs.toml | 79 ++++++++++++++++++++++++++++ config/zsh/.zshrc | 4 ++ config/zsh/broot.zsh | 23 +++++++++ 7 files changed, 360 insertions(+) create mode 100644 config/broot/conf.toml create mode 100644 config/broot/launcher/refused create mode 100644 config/broot/skins/dark.toml create mode 100644 config/broot/skins/light.toml create mode 100644 config/broot/verbs.toml create mode 100644 config/zsh/broot.zsh diff --git a/config/broot/conf.toml b/config/broot/conf.toml new file mode 100644 index 0000000..4708066 --- /dev/null +++ b/config/broot/conf.toml @@ -0,0 +1,56 @@ +############################################################### +# Configuration documentation is available at +# https://dystroy.org/broot +############################################################### + +# Column order +cols_order = [ + "permission", + "count", + "size", + "date", + "mark", + "git", + "branch", + "name", +] + +# Max file size for content search +content_search_max_file_size = "10MB" + +date_time_format = "%Y-%m-%d %R" + +default_flags = "--sort-by-type --no-trim-root" + +# Show NerdFont icons. +icon_theme = "nerdfont" + +imports = [ + "verbs.toml", + { luma = ["dark", "unknown"], file = "skins/dark.toml" }, + { luma = "light", file = "skins/light.toml" }, +] + +# Whether to mark the selected line with a triangle +show_selection_mark = true + +# Special paths +# ============= +# "list":"never" on a dir prevents broot from looking at its +# children when searching, unless the dir is the selected root. +# "sum":"never" on a dir prevents broot from looking at its +# children when computing the total size and count of files. +# "show":"always" makes a file visible even if its name +# starts with a dot. +# "list":"always" may be useful on a link to a directory +# (they're otherwise not entered by broot unless selected) +[special_paths."/media"] +list = "never" +sum = "never" + +[special_paths."~/.config"] +show = "always" + +# Quit if there is nothing else to escape. +quit_on_last_cancel = true + diff --git a/config/broot/launcher/refused b/config/broot/launcher/refused new file mode 100644 index 0000000..d206403 --- /dev/null +++ b/config/broot/launcher/refused @@ -0,0 +1,4 @@ + +This file tells broot you refused the installation of the companion shell function. +If you want to install it run + broot -- install diff --git a/config/broot/skins/dark.toml b/config/broot/skins/dark.toml new file mode 100644 index 0000000..a86fb02 --- /dev/null +++ b/config/broot/skins/dark.toml @@ -0,0 +1,97 @@ +################################################################################ +# A skin for a terminal with a dark background +# Created by Fernando Schauenburg +# +# Example colors from tokyonight: +# +# NAME RGB Index +# black rgb(21, 22, 30) ansi(0) +# br_black rgb(65, 72, 104) ansi(8) +# red rgb(247, 118, 142) ansi(1) +# green rgb(158, 206, 106) ansi(2) +# yellow rgb(224, 175, 104) ansi(3) +# blue rgb(122, 162, 247) ansi(4) +# magenta rgb(187, 154, 247) ansi(5) +# cyan rgb(125, 207, 255) ansi(6) +# white rgb(169, 177, 214) ansi(7) +# br_white rgb(192, 202, 245) ansi(15) +# +# Doc at https://dystroy.org/broot/skins/ +################################################################################ +[skin] +default = "ansi(7)" +input = "ansi(7)" +selected_line = "none ansi(0)" +tree = "ansi(8)" +parent = "none" +perm__ = "ansi(8)" +perm_r = "ansi(3)" +perm_w = "ansi(1)" +perm_x = "ansi(2)" +count = "ansi(1)" +owner = "ansi(3)" +group = "ansi(3)" +dates = "ansi(4)" +file = "ansi(15)" +directory = "ansi(4) none Bold" +exe = "ansi(2) none Bold" +link = "ansi(6)" +pruning = "ansi(8) none Italic" +content_extract = "ansi(244) none Italic" +char_match = "ansi(3) ansi(0) Bold Italic" +preview_match = "ansi(3) ansi(0) Bold Italic" +content_match = "ansi(3) ansi(0) Bold Italic" +git_branch = "ansi(4) none Bold" +git_insertions = "ansi(2) none Bold" +git_deletions = "ansi(1) none Bold" +git_status_current = "ansi(8)" +git_status_modified = "ansi(4)" +git_status_new = "ansi(2) none Bold" +git_status_ignored = "ansi(8)" +git_status_conflicted = "ansi(1)" +git_status_other = "ansi(7)" +help_paragraph = "ansi(7)" +help_headers = "ansi(3) none Bold" +help_bold = "ansi(4) none Bold" +help_italic = "ansi(6) none Italic" +help_code = "ansi(3) none Bold" +help_table_border = "ansi(8)" +scrollbar_track = "ansi(8)" +scrollbar_thumb = "ansi(7)" +flag_label = "ansi(4)" +flag_value = "ansi(3) none Bold" +staging_area_title = "ansi(3) none Bold" +preview_title = "ansi(0) ansi(3) Bold" +preview = "ansi(7)" +preview_line_number = "ansi(8)" +# sparse = "ansi(1)" +status_normal = "none ansi(0)" +status_italic = "ansi(6) Italic" +status_bold = "ansi(4) Bold" +# status_ellipsis = "ansi(3)" +status_error = "ansi(1) ansi(0)" +# status_job = "ansi(3)" +status_code = "ansi(3)" +mode_command_mark = "ansi(0) ansi(3) Bold" +hex_null = "ansi(7)" +hex_ascii_graphic = "ansi(2)" +hex_ascii_whitespace = "ansi(2) ansi(0) Italic" +hex_ascii_other = "ansi(2) none Bold" +hex_non_ascii = "ansi(1) Bold" +file_error = "ansi(1) none" +purpose_normal = "red" +# purpose_italic = "ansi(1) none Italic" +# purpose_bold = "ansi(1) none Bold" +# purpose_ellipsis = "none" + +good_to_bad_0 = "rgb(166, 227, 161)" +good_to_bad_1 = "rgb(148, 226, 213)" +good_to_bad_2 = "rgb(137, 220, 235)" +good_to_bad_3 = "rgb(116, 199, 236)" +good_to_bad_4 = "rgb(137, 180, 250)" +good_to_bad_5 = "rgb(180, 190, 254)" +good_to_bad_6 = "rgb(203, 166, 247)" +good_to_bad_7 = "rgb(250, 179, 135)" +good_to_bad_8 = "rgb(235, 160, 172)" +good_to_bad_9 = "rgb(243, 139, 168)" + diff --git a/config/broot/skins/light.toml b/config/broot/skins/light.toml new file mode 100644 index 0000000..a5ea37e --- /dev/null +++ b/config/broot/skins/light.toml @@ -0,0 +1,97 @@ +################################################################################ +# A skin for a terminal with a dark background +# Created by Fernando Schauenburg +# +# Example colors from tokyonight: +# +# NAME RGB Index +# black rgb(192, 202, 245) ansi(0) +# br_black rgb(169, 177, 214) ansi(8) +# red rgb(247, 118, 142) ansi(1) +# green rgb(158, 206, 106) ansi(2) +# yellow rgb(224, 175, 104) ansi(3) +# blue rgb(122, 162, 247) ansi(4) +# magenta rgb(187, 154, 247) ansi(5) +# cyan rgb(125, 207, 255) ansi(6) +# white rgb(65, 72, 104) ansi(7) +# br_white rgb(21, 22, 30) ansi(15) +# +# Doc at https://dystroy.org/broot/skins/ +################################################################################ +[skin] +default = "ansi(8)" +input = "ansi(8)" +selected_line = "none ansi(15)" +tree = "ansi(7)" +parent = "none" +perm__ = "ansi(7)" +perm_r = "ansi(3)" +perm_w = "ansi(1)" +perm_x = "ansi(2)" +count = "ansi(1)" +owner = "ansi(3)" +group = "ansi(3)" +dates = "ansi(4)" +file = "ansi(0)" +directory = "ansi(4) none Bold" +exe = "ansi(2) none Bold" +link = "ansi(6)" +pruning = "ansi(7) none Italic" +content_extract = "ansi(244) none Italic" +char_match = "ansi(3) ansi(15) Bold Italic" +preview_match = "ansi(3) ansi(15) Bold Italic" +content_match = "ansi(3) ansi(15) Bold Italic" +git_branch = "ansi(4) none Bold" +git_insertions = "ansi(2) none Bold" +git_deletions = "ansi(1) none Bold" +git_status_current = "ansi(7)" +git_status_modified = "ansi(4)" +git_status_new = "ansi(2) none Bold" +git_status_ignored = "ansi(7)" +git_status_conflicted = "ansi(1)" +git_status_other = "ansi(8)" +help_paragraph = "ansi(8)" +help_headers = "ansi(3) none Bold" +help_bold = "ansi(4) none Bold" +help_italic = "ansi(6) none Italic" +help_code = "ansi(3) none Bold" +help_table_border = "ansi(7)" +scrollbar_track = "ansi(7)" +scrollbar_thumb = "ansi(8)" +flag_label = "ansi(4)" +flag_value = "ansi(3) none Bold" +staging_area_title = "ansi(3) none Bold" +preview_title = "ansi(15) ansi(3) Bold" +preview = "ansi(8)" +preview_line_number = "ansi(7)" +# sparse = "ansi(1)" +status_normal = "none ansi(15)" +status_italic = "ansi(6) Italic" +status_bold = "ansi(4) Bold" +# status_ellipsis = "ansi(3)" +status_error = "ansi(1) ansi(15)" +# status_job = "ansi(3)" +status_code = "ansi(3)" +mode_command_mark = "ansi(15) ansi(3) Bold" +hex_null = "ansi(8)" +hex_ascii_graphic = "ansi(2)" +hex_ascii_whitespace = "ansi(2) ansi(15) Italic" +hex_ascii_other = "ansi(2) none Bold" +hex_non_ascii = "ansi(1) Bold" +file_error = "ansi(1) none" +purpose_normal = "red" +# purpose_italic = "ansi(1) none Italic" +# purpose_bold = "ansi(1) none Bold" +# purpose_ellipsis = "none" + +good_to_bad_0 = "rgb(166, 227, 161)" +good_to_bad_1 = "rgb(148, 226, 213)" +good_to_bad_2 = "rgb(137, 220, 235)" +good_to_bad_3 = "rgb(116, 199, 236)" +good_to_bad_4 = "rgb(137, 180, 250)" +good_to_bad_5 = "rgb(180, 190, 254)" +good_to_bad_6 = "rgb(203, 166, 247)" +good_to_bad_7 = "rgb(250, 179, 135)" +good_to_bad_8 = "rgb(235, 160, 172)" +good_to_bad_9 = "rgb(243, 139, 168)" + diff --git a/config/broot/verbs.toml b/config/broot/verbs.toml new file mode 100644 index 0000000..5a81212 --- /dev/null +++ b/config/broot/verbs.toml @@ -0,0 +1,79 @@ +############################################################### +# This file contains the verb definitions for broot +# +# Documentation at https://dystroy.org/broot/verbs/ +############################################################### + +[[verbs]] +invocation = "edit" +shortcut = "e" +key = "enter" +apply_to = "text_file" +execution = "nvim +{line} {file}" +leave_broot = false + +[[verbs]] +name = "touch" +invocation = "touch {new_file}" +execution = "touch {directory}/{new_file}" +leave_broot = false + +[[verbs]] +invocation = "create {subpath}" +execution = "$EDITOR {directory}/{subpath}" +leave_broot = false + +[[verbs]] +invocation = "git_diff" +shortcut = "gd" +leave_broot = false +execution = "git difftool -y {file}" + +[[verbs]] +invocation = "backup {version}" +key = "ctrl-b" +leave_broot = false +auto_exec = false +execution = "cp -r {file} {file}.{version}" +# execution = "cp -r {file} {parent}/{file-stem}{version}{file-dot-extension}" + +[[verbs]] +invocation = "terminal" +key = "ctrl-t" +execution = "$SHELL" +set_working_dir = true +leave_broot = false + +[[verbs]] +invocation = "git_root" +shortcut = "gtr" +execution = ":focus {git-root}" + +[[verbs]] +key = "ctrl-c" +execution = ":escape" + +[[verbs]] +key = "ctrl-h" +execution = ":panel_left_no_open" + +[[verbs]] +key = "ctrl-l" +execution = ":panel_right" + +[[verbs]] +key = "ctrl-k" +execution = ":line_up" + +[[verbs]] +key = "ctrl-j" +execution = ":line_down" + +[[verbs]] +key = "ctrl-u" +execution = ":page_up" + +[[verbs]] +key = "ctrl-d" +execution = ":page_down" + diff --git a/config/zsh/.zshrc b/config/zsh/.zshrc index c5d856e..7a41b0e 100644 --- a/config/zsh/.zshrc +++ b/config/zsh/.zshrc @@ -6,6 +6,10 @@ source "$ZDOTDIR/line-editor.zsh" source "$ZDOTDIR/man-pages.zsh" source "$ZDOTDIR/prompt.zsh" +if command -v broot >/dev/null 2>&1; then + source "$ZDOTDIR/broot.zsh" +fi + # Set up autoload for custom functions. fpath=("$ZDOTDIR/functions" $fpath) for filepath in $ZDOTDIR/functions/*; do diff --git a/config/zsh/broot.zsh b/config/zsh/broot.zsh new file mode 100644 index 0000000..9bbbf3b --- /dev/null +++ b/config/zsh/broot.zsh @@ -0,0 +1,23 @@ +# This function 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 --outcmd "$cmd_file" "$@"; then + cmd=$(<"$cmd_file") + command rm -f "$cmd_file" + eval "$cmd" + else + code=$? + command rm -f "$cmd_file" + return "$code" + fi +} + +# Shortcut to start neovim. +bindkey -s '^b' '^ubr\r' +