diff --git a/.dockerfile/root/.bashrc b/.dockerfile/home/.bashrc similarity index 100% rename from .dockerfile/root/.bashrc rename to .dockerfile/home/.bashrc diff --git a/.dockerfile/root/.config/elvish/rc.elv b/.dockerfile/home/.config/elvish/rc.elv similarity index 100% rename from .dockerfile/root/.config/elvish/rc.elv rename to .dockerfile/home/.config/elvish/rc.elv diff --git a/.dockerfile/root/.config/fish/config.fish b/.dockerfile/home/.config/fish/config.fish similarity index 100% rename from .dockerfile/root/.config/fish/config.fish rename to .dockerfile/home/.config/fish/config.fish diff --git a/.dockerfile/root/.config/ion/initrc b/.dockerfile/home/.config/ion/initrc similarity index 100% rename from .dockerfile/root/.config/ion/initrc rename to .dockerfile/home/.config/ion/initrc diff --git a/.dockerfile/root/.config/nushell/config.nu b/.dockerfile/home/.config/nushell/config.nu similarity index 77% rename from .dockerfile/root/.config/nushell/config.nu rename to .dockerfile/home/.config/nushell/config.nu index d397c985d..6d996e820 100644 --- a/.dockerfile/root/.config/nushell/config.nu +++ b/.dockerfile/home/.config/nushell/config.nu @@ -1,6 +1,6 @@ # Nushell Config File # -# version = "0.85.0" +# version = "0.91.0" # For more information on defining custom themes, see # https://www.nushell.sh/book/coloring_and_theming.html @@ -31,7 +31,7 @@ let dark_theme = { list: white block: white hints: dark_gray - search_result: {bg: red fg: white} + search_result: { bg: red fg: white } shape_and: purple_bold shape_binary: purple_bold shape_block: blue_bold @@ -42,6 +42,7 @@ let dark_theme = { shape_directory: cyan shape_external: cyan shape_externalarg: green_bold + shape_external_resolved: light_yellow_bold shape_filepath: cyan shape_flag: blue_bold shape_float: purple_bold @@ -50,6 +51,7 @@ let dark_theme = { shape_globpattern: cyan_bold shape_int: purple_bold shape_internalcall: cyan_bold + shape_keyword: cyan_bold shape_list: cyan_bold shape_literal: blue shape_match_pattern: green @@ -90,11 +92,11 @@ let light_theme = { binary: dark_gray cell-path: dark_gray row_index: green_bold - record: white - list: white - block: white + record: dark_gray + list: dark_gray + block: dark_gray hints: dark_gray - search_result: {fg: white bg: red} + search_result: { fg: white bg: red } shape_and: purple_bold shape_binary: purple_bold shape_block: blue_bold @@ -105,6 +107,7 @@ let light_theme = { shape_directory: cyan shape_external: cyan shape_externalarg: green_bold + shape_external_resolved: light_purple_bold shape_filepath: cyan shape_flag: blue_bold shape_float: purple_bold @@ -113,6 +116,7 @@ let light_theme = { shape_globpattern: cyan_bold shape_int: purple_bold shape_internalcall: cyan_bold + shape_keyword: cyan_bold shape_list: cyan_bold shape_literal: blue shape_match_pattern: green @@ -135,7 +139,7 @@ let light_theme = { # External completer example let carapace_completer = {|spans| if "TARGET" in $env { - ^$env.TARGET _carapace nushell $spans | from json + ^$env.TARGET _carapace nushell ...$spans | from json } } @@ -152,10 +156,6 @@ $env.config = { always_trash: false # always act as if -t was given. Can be overridden with -p } - cd: { - abbreviations: false # allows `cd s/o/f` to expand to `cd some/other/folder` - } - table: { mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column @@ -167,6 +167,7 @@ $env.config = { truncating_suffix: "..." # A suffix used by the 'truncating' methodology } header_on_separator: false # show header text on separator/border line + # abbreviated_row_count: 10 # limit data rows from top and bottom after reaching a set point } error_style: "fancy" # "fancy" or "plain" for screen reader-friendly error messages @@ -180,24 +181,19 @@ $env.config = { } explore: { - status_bar_background: {fg: "#1D1F21", bg: "#C4C9C6"}, - command_bar_text: {fg: "#C4C9C6"}, - highlight: {fg: "black", bg: "yellow"}, + status_bar_background: { fg: "#1D1F21", bg: "#C4C9C6" }, + command_bar_text: { fg: "#C4C9C6" }, + highlight: { fg: "black", bg: "yellow" }, status: { - error: {fg: "white", bg: "red"}, + error: { fg: "white", bg: "red" }, warn: {} info: {} }, table: { - split_line: {fg: "#404040"}, - selected_cell: {}, + split_line: { fg: "#404040" }, + selected_cell: { bg: light_blue }, selected_row: {}, selected_column: {}, - show_cursor: true, - line_head_top: true, - line_head_bottom: true, - line_shift: true, - line_index: true, }, } @@ -218,10 +214,11 @@ $env.config = { max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options completer: $carapace_completer # check 'carapace_completer' above as an example } + use_ls_colors: true # set this to true to enable file/path/directory completions using LS_COLORS } filesize: { - metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + metric: false # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto } @@ -241,6 +238,10 @@ $env.config = { edit_mode: emacs # emacs, vi shell_integration: false # enables terminal shell integration. Off by default, as some terminals have issues with this. render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. + use_kitty_protocol: false # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this. + highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which. + + plugins: {} # Per-plugin configuration. See https://www.nushell.sh/contributor-book/plugins.html#configuration. hooks: { pre_prompt: [{ null }] # run before the prompt is shown @@ -265,10 +266,43 @@ $env.config = { col_width: 20 # Optional value. If missing all the screen width is used to calculate column width col_padding: 2 } + style: { + text: white + selected_text: {attr: r} + description_text: white_dimmed + } + } + { + name: ide_completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: ide + min_completion_width: 0, + max_completion_width: 50, + max_completion_height: 10, # will be limited by the available lines in the terminal + padding: 0, + border: true, + cursor_offset: 0, + description_mode: "prefer_right" + min_description_width: 0 + max_description_width: 50 + max_description_height: 10 + description_offset: 1 + # If true, the cursor pos will be corrected, so the suggestions match up with the typed text + # + # C:\> str + # str join + # str trim + # str split + correct_cursor_pos: false + } style: { text: green - selected_text: green_reverse + selected_text: { attr: r } description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } } } { @@ -319,6 +353,19 @@ $env.config = { ] } } + { + name: ide_completion_menu + modifier: control + keycode: char_n + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: ide_completion_menu } + { send: menunext } + { edit: complete } + ] + } + } { name: history_menu modifier: control @@ -408,8 +455,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: menuup} - {send: up} + { send: menuup } + { send: up } ] } } @@ -420,8 +467,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: menudown} - {send: down} + { send: menudown } + { send: down } ] } } @@ -432,8 +479,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: menuleft} - {send: left} + { send: menuleft } + { send: left } ] } } @@ -444,9 +491,9 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: historyhintcomplete} - {send: menuright} - {send: right} + { send: historyhintcomplete } + { send: menuright } + { send: right } ] } } @@ -455,7 +502,7 @@ $env.config = { modifier: control keycode: left mode: [emacs, vi_normal, vi_insert] - event: {edit: movewordleft} + event: { edit: movewordleft } } { name: move_one_word_right_or_take_history_hint @@ -464,8 +511,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: historyhintwordcomplete} - {edit: movewordright} + { send: historyhintwordcomplete } + { edit: movewordright } ] } } @@ -474,14 +521,14 @@ $env.config = { modifier: none keycode: home mode: [emacs, vi_normal, vi_insert] - event: {edit: movetolinestart} + event: { edit: movetolinestart } } { name: move_to_line_start modifier: control keycode: char_a mode: [emacs, vi_normal, vi_insert] - event: {edit: movetolinestart} + event: { edit: movetolinestart } } { name: move_to_line_end_or_take_history_hint @@ -490,8 +537,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: historyhintcomplete} - {edit: movetolineend} + { send: historyhintcomplete } + { edit: movetolineend } ] } } @@ -502,8 +549,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: historyhintcomplete} - {edit: movetolineend} + { send: historyhintcomplete } + { edit: movetolineend } ] } } @@ -512,14 +559,14 @@ $env.config = { modifier: control keycode: home mode: [emacs, vi_normal, vi_insert] - event: {edit: movetolinestart} + event: { edit: movetolinestart } } { name: move_to_line_end modifier: control keycode: end mode: [emacs, vi_normal, vi_insert] - event: {edit: movetolineend} + event: { edit: movetolineend } } { name: move_up @@ -528,8 +575,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: menuup} - {send: up} + { send: menuup } + { send: up } ] } } @@ -540,8 +587,8 @@ $env.config = { mode: [emacs, vi_normal, vi_insert] event: { until: [ - {send: menudown} - {send: down} + { send: menudown } + { send: down } ] } } @@ -550,56 +597,56 @@ $env.config = { modifier: none keycode: backspace mode: [emacs, vi_insert] - event: {edit: backspace} + event: { edit: backspace } } { name: delete_one_word_backward modifier: control keycode: backspace mode: [emacs, vi_insert] - event: {edit: backspaceword} + event: { edit: backspaceword } } { name: delete_one_character_forward modifier: none keycode: delete mode: [emacs, vi_insert] - event: {edit: delete} + event: { edit: delete } } { name: delete_one_character_forward modifier: control keycode: delete mode: [emacs, vi_insert] - event: {edit: delete} + event: { edit: delete } } { - name: delete_one_character_forward + name: delete_one_character_backward modifier: control keycode: char_h mode: [emacs, vi_insert] - event: {edit: backspace} + event: { edit: backspace } } { name: delete_one_word_backward modifier: control keycode: char_w mode: [emacs, vi_insert] - event: {edit: backspaceword} + event: { edit: backspaceword } } { name: move_left modifier: none keycode: backspace mode: vi_normal - event: {edit: moveleft} + event: { edit: moveleft } } { name: newline_or_run_command modifier: none keycode: enter mode: emacs - event: {send: enter} + event: { send: enter } } { name: move_left @@ -608,8 +655,8 @@ $env.config = { mode: emacs event: { until: [ - {send: menuleft} - {send: left} + { send: menuleft } + { send: left } ] } } @@ -620,9 +667,9 @@ $env.config = { mode: emacs event: { until: [ - {send: historyhintcomplete} - {send: menuright} - {send: right} + { send: historyhintcomplete } + { send: menuright } + { send: right } ] } } @@ -631,56 +678,56 @@ $env.config = { modifier: control keycode: char_g mode: emacs - event: {edit: redo} + event: { edit: redo } } { name: undo_change modifier: control keycode: char_z mode: emacs - event: {edit: undo} + event: { edit: undo } } { name: paste_before modifier: control keycode: char_y mode: emacs - event: {edit: pastecutbufferbefore} + event: { edit: pastecutbufferbefore } } { name: cut_word_left modifier: control keycode: char_w mode: emacs - event: {edit: cutwordleft} + event: { edit: cutwordleft } } { name: cut_line_to_end modifier: control keycode: char_k mode: emacs - event: {edit: cuttoend} + event: { edit: cuttoend } } { name: cut_line_from_start modifier: control keycode: char_u mode: emacs - event: {edit: cutfromstart} + event: { edit: cutfromstart } } { name: swap_graphemes modifier: control keycode: char_t mode: emacs - event: {edit: swapgraphemes} + event: { edit: swapgraphemes } } { name: move_one_word_left modifier: alt keycode: left mode: emacs - event: {edit: movewordleft} + event: { edit: movewordleft } } { name: move_one_word_right_or_take_history_hint @@ -689,8 +736,8 @@ $env.config = { mode: emacs event: { until: [ - {send: historyhintwordcomplete} - {edit: movewordright} + { send: historyhintwordcomplete } + { edit: movewordright } ] } } @@ -699,7 +746,7 @@ $env.config = { modifier: alt keycode: char_b mode: emacs - event: {edit: movewordleft} + event: { edit: movewordleft } } { name: move_one_word_right_or_take_history_hint @@ -708,8 +755,8 @@ $env.config = { mode: emacs event: { until: [ - {send: historyhintwordcomplete} - {edit: movewordright} + { send: historyhintwordcomplete } + { edit: movewordright } ] } } @@ -718,49 +765,77 @@ $env.config = { modifier: alt keycode: delete mode: emacs - event: {edit: deleteword} + event: { edit: deleteword } } { name: delete_one_word_backward modifier: alt keycode: backspace mode: emacs - event: {edit: backspaceword} + event: { edit: backspaceword } } { name: delete_one_word_backward modifier: alt keycode: char_m mode: emacs - event: {edit: backspaceword} + event: { edit: backspaceword } } { name: cut_word_to_right modifier: alt keycode: char_d mode: emacs - event: {edit: cutwordright} + event: { edit: cutwordright } } { name: upper_case_word modifier: alt keycode: char_u mode: emacs - event: {edit: uppercaseword} + event: { edit: uppercaseword } } { name: lower_case_word modifier: alt keycode: char_l mode: emacs - event: {edit: lowercaseword} + event: { edit: lowercaseword } } { name: capitalize_char modifier: alt keycode: char_c mode: emacs - event: {edit: capitalizechar} + event: { edit: capitalizechar } + } + { + name: copy_selection + modifier: control_shift + keycode: char_c + mode: emacs + event: { edit: copyselection } + } + { + name: cut_selection + modifier: control_shift + keycode: char_x + mode: emacs + event: { edit: cutselection } + } + { + name: select_all + modifier: control_shift + keycode: char_a + mode: emacs + event: { edit: selectall } + } + { + name: paste + modifier: control_shift + keycode: char_v + mode: emacs + event: { edit: pastecutbufferbefore } } ] } diff --git a/.dockerfile/root/.config/nushell/env.nu b/.dockerfile/home/.config/nushell/env.nu similarity index 61% rename from .dockerfile/root/.config/nushell/env.nu rename to .dockerfile/home/.config/nushell/env.nu index e8258f09f..44ce32bbc 100644 --- a/.dockerfile/root/.config/nushell/env.nu +++ b/.dockerfile/home/.config/nushell/env.nu @@ -1,20 +1,19 @@ # Nushell Environment Config File # -# version = "0.85.0" +# version = "0.91.0" def create_left_prompt [] { - let home = $nu.home-path - - let dir = ([ - ($env.PWD | str substring 0..($home | str length) | str replace $home "~"), - ($env.PWD | str substring ($home | str length)..) - ] | str join) + let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) { + null => $env.PWD + '' => '~' + $relative_pwd => ([~ $relative_pwd] | path join) + } let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) let path_segment = $"($path_color)($dir)" - $path_segment | str replace --all (char path_sep) $"($separator_color)/($path_color)" + $path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)" } def create_right_prompt [] { @@ -22,7 +21,7 @@ def create_right_prompt [] { let time_segment = ([ (ansi reset) (ansi magenta) - (date now | format date '%x %X %p') # try to respect user's locale + (date now | format date '%x %X') # try to respect user's locale ] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" | str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}") @@ -47,6 +46,18 @@ $env.PROMPT_INDICATOR_VI_INSERT = {|| ": " } $env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " } $env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } +# If you want previously entered commands to have a different prompt from the usual one, +# you can uncomment one or more of the following lines. +# This can be useful if you have a 2-line prompt and it's taking up a lot of space +# because every command entered takes up 2 lines instead of 1. You can then uncomment +# the line below so that previously entered commands show with a single `🚀`. +# $env.TRANSIENT_PROMPT_COMMAND = {|| "🚀 " } +# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" } +# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" } + # Specifies how environment variables are: # - converted from a string to a value on Nushell startup (from_string) # - converted from a value back to a string when running external commands (to_string) @@ -63,16 +74,27 @@ $env.ENV_CONVERSIONS = { } # Directories to search for scripts when calling source or use +# The default for this is $nu.default-config-dir/scripts $env.NU_LIB_DIRS = [ - # FIXME: This default is not implemented in rust code as of 2023-09-06. ($nu.default-config-dir | path join 'scripts') # add /scripts ] # Directories to search for plugin binaries when calling register +# The default for this is $nu.default-config-dir/plugins $env.NU_PLUGIN_DIRS = [ - # FIXME: This default is not implemented in rust code as of 2023-09-06. ($nu.default-config-dir | path join 'plugins') # add /plugins ] # To add entries to PATH (on Windows you might use Path), you can use the following pattern: # $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') +# An alternate way to add entries to $env.PATH is to use the custom command `path add` +# which is built into the nushell stdlib: +# use std "path add" +# $env.PATH = ($env.PATH | split row (char esep)) +# path add /some/path +# path add ($env.CARGO_HOME | path join "bin") +# path add ($env.HOME | path join ".local" "bin") +# $env.PATH = ($env.PATH | uniq) + +# To load from a custom file you can use: +# source ($nu.default-config-dir | path join 'custom.nu') diff --git a/.dockerfile/root/.config/nushell/starship.nu b/.dockerfile/home/.config/nushell/starship.nu similarity index 100% rename from .dockerfile/root/.config/nushell/starship.nu rename to .dockerfile/home/.config/nushell/starship.nu diff --git a/.dockerfile/root/.config/oil/oshrc b/.dockerfile/home/.config/oils/oshrc similarity index 100% rename from .dockerfile/root/.config/oil/oshrc rename to .dockerfile/home/.config/oils/oshrc diff --git a/.dockerfile/root/.config/powershell/Microsoft.PowerShell_profile.ps1 b/.dockerfile/home/.config/powershell/Microsoft.PowerShell_profile.ps1 similarity index 82% rename from .dockerfile/root/.config/powershell/Microsoft.PowerShell_profile.ps1 rename to .dockerfile/home/.config/powershell/Microsoft.PowerShell_profile.ps1 index 6a2a4b6a3..cff246ee5 100644 --- a/.dockerfile/root/.config/powershell/Microsoft.PowerShell_profile.ps1 +++ b/.dockerfile/home/.config/powershell/Microsoft.PowerShell_profile.ps1 @@ -1,8 +1,13 @@ $env:SHELL = 'powershell' $env:STARSHIP_SHELL = 'powershell' $env:LS_COLORS = (&vivid generate dracula) + Invoke-Expression (&starship init powershell) + + +Set-PSReadLineOption -Colors @{ "Selection" = "`e[7m" } Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete + if ($Env:TARGET){ & $Env:TARGET _carapace | out-string | Invoke-Expression } diff --git a/.dockerfile/root/.config/starship.toml b/.dockerfile/home/.config/starship.toml similarity index 100% rename from .dockerfile/root/.config/starship.toml rename to .dockerfile/home/.config/starship.toml diff --git a/.dockerfile/root/.config/xonsh/rc.xsh b/.dockerfile/home/.config/xonsh/rc.xsh similarity index 85% rename from .dockerfile/root/.config/xonsh/rc.xsh rename to .dockerfile/home/.config/xonsh/rc.xsh index 62c609362..a9cb57284 100644 --- a/.dockerfile/root/.config/xonsh/rc.xsh +++ b/.dockerfile/home/.config/xonsh/rc.xsh @@ -2,5 +2,8 @@ $SHELL="xonsh" $STARSHIP_SHELL="xonsh" $LS_COLORS=$(vivid generate dracula) $PROMPT=lambda: $(starship prompt) + $COMPLETIONS_CONFIRM=True +$COMPLETION_QUERY_LIMIT = 500 + 'TARGET' in ${...} && exec($($TARGET _carapace xonsh)) diff --git a/.dockerfile/root/.tcshrc b/.dockerfile/home/.tcshrc similarity index 100% rename from .dockerfile/root/.tcshrc rename to .dockerfile/home/.tcshrc diff --git a/.dockerfile/root/.zshrc b/.dockerfile/home/.zshrc similarity index 100% rename from .dockerfile/root/.zshrc rename to .dockerfile/home/.zshrc diff --git a/Dockerfile b/Dockerfile index ab158fc5b..6d5bcbce3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,7 @@ RUN apt-get update \ elvish \ expect \ shellcheck \ + sudo \ tcsh \ xonsh \ zsh @@ -96,8 +97,15 @@ COPY --from=oil /usr/local/bin/* /usr/local/bin/ COPY --from=starship /usr/local/bin/* /usr/local/bin/ COPY --from=vivid /usr/local/bin/* /usr/local/bin/ -ADD .dockerfile/root /root -ADD .dockerfile/usr/local/bin/* /usr/local/bin/ +RUN groupadd --gid 1000 carapace \ + && useradd --uid 1000 --gid 1000 --create-home carapace \ + && mkdir /.cache \ + && chmod -R a+rwx /.cache /go /opt \ + && echo " carapace ALL = NOPASSWD: ALL" >> /etc/sudoers + +COPY .dockerfile/home /root/ +COPY --chown=1000:1000 .dockerfile/home /home/carapace/ +COPY .dockerfile/usr/local/bin/* /usr/local/bin/ ENV TERM xterm ENTRYPOINT [ "entrypoint.sh" ] diff --git a/docker-compose.yml b/docker-compose.yml index 04ea586b4..43ca54412 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: build: . image: ghcr.io/rsteube/carapace command: sh -c 'cd /carapace/example && go build -buildvcs=false .' + user: 1000:1000 environment: TARGET: /carapace/example/example volumes: