repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
nushell/config.nu
Raw# Nushell Config File
use environment.nu *
use table.nu *
use os.nu *
use prompt.nu *
use aliases.nu *
use todo.nu *
use git.nu *
# for more information on themes see
# https://github.com/nushell/nushell/blob/main/docs/How_To_Coloring_and_Theming.md
let default_theme = {
# color for nushell primitives
separator: white
leading_trailing_space_bg: { attr: n } # no fg, no bg, attr non effectively turns this off
header: green_bold
empty: blue
bool: white
int: white
filesize: white
duration: white
date: white
range: white
float: white
string: white
nothing: white
binary: white
cellpath: white
row_index: green_bold
record: white
list: white
block: white
hints: dark_gray
# shapes are used to change the cli syntax highlighting
shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b}
shape_binary: purple_bold
shape_bool: light_cyan
shape_int: purple_bold
shape_float: purple_bold
shape_range: yellow_bold
shape_internalcall: cyan_bold
shape_external: cyan
shape_externalarg: green_bold
shape_literal: blue
shape_operator: yellow
shape_signature: green_bold
shape_string: green
shape_string_interpolation: cyan_bold
shape_datetime: cyan_bold
shape_list: cyan_bold
shape_table: blue_bold
shape_record: cyan_bold
shape_block: blue_bold
shape_filepath: cyan
shape_globpattern: cyan_bold
shape_variable: purple
shape_flag: blue_bold
shape_custom: green
shape_nothing: light_cyan
}
# The default config record. This is where much of your global configuration is setup.
let $config = {
filesize_metric: false
table_mode: light # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
use_ls_colors: true
rm_always_trash: true
color_config: $default_theme
use_grid_icons: true
footer_mode: "auto" # always, never, number_of_rows, auto
quick_completions: false # set this to false to prevent auto-selecting completions when only one remains
partial_completions: false # set this to false to prevent partial filling of the prompt
animate_prompt: false # redraw the prompt every second
float_precision: 2
use_ansi_coloring: true
filesize_format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto
edit_mode: emacs # emacs, vi
max_history_size: 10000
sync_history_on_enter: true # Enable to share the history between multiple sessions, else you have to close the session to persist history to file
menus: [
# Configuration for default nushell menus
# Note the lack of souce parameter
{
name: completion_menu
only_buffer_difference: false
marker: "| "
type: {
layout: columnar
columns: 4
col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
col_padding: 2
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
}
{
name: history_menu
only_buffer_difference: true
marker: "? "
type: {
layout: list
page_size: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
}
{
name: help_menu
only_buffer_difference: true
marker: "? "
type: {
layout: description
columns: 4
col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
col_padding: 2
selection_rows: 4
description_rows: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
}
# Example of extra menus created using a nushell source
# Use the source field to create a list of records that populates
# the menu
{
name: commands_menu
only_buffer_difference: false
marker: "# "
type: {
layout: columnar
columns: 4
col_width: 20
col_padding: 2
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
$nu.scope.commands
| where command =~ $buffer
| each { |it| {value: $it.command description: $it.usage} }
}
}
{
name: vars_menu
only_buffer_difference: true
marker: "# "
type: {
layout: list
page_size: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
$nu.scope.vars
| where name =~ $buffer
| sort-by name
| each { |it| {value: $it.name description: $it.type} }
}
}
{
name: commands_with_description
only_buffer_difference: true
marker: "# "
type: {
layout: description
columns: 4
col_width: 20
col_padding: 2
selection_rows: 4
description_rows: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
$nu.scope.commands
| where command =~ $buffer
| each { |it| {value: $it.command description: $it.usage} }
}
}
]
keybindings: [
{
name: completion_menu
modifier: none
keycode: tab
mode: emacs # Options: emacs vi_normal vi_insert
event: {
until: [
{ send: menu name: completion_menu }
{ send: menunext }
]
}
}
{
name: completion_previous
modifier: shift
keycode: backtab
mode: [emacs, vi_normal, vi_insert] # Note: You can add the same keybinding to all modes by using a list
event: { send: menuprevious }
}
{
name: history_menu
modifier: control
keycode: char_x
mode: emacs
event: {
until: [
{ send: menu name: history_menu }
{ send: menupagenext }
]
}
}
{
name: history_previous
modifier: control
keycode: char_z
mode: emacs
event: {
until: [
{ send: menupageprevious }
{ edit: undo }
]
}
}
# Keybindings used to trigger the user defined menus
{
name: commands_menu
modifier: control
keycode: char_t
mode: [emacs, vi_normal, vi_insert]
event: { send: menu name: commands_menu }
}
{
name: vars_menu
modifier: control
keycode: char_y
mode: [emacs, vi_normal, vi_insert]
event: { send: menu name: vars_menu }
}
{
name: commands_with_description
modifier: control
keycode: char_u
mode: [emacs, vi_normal, vi_insert]
event: { send: menu name: commands_with_description }
} ]
}
# CUSTOM COMPLETIONS
module svn {
def "complete svn subcommands" [] {
^svn help
| lines
| skip until { | line | $line | str starts-with "Available subcommands:" }
| skip 1
| each { |line| $line | str trim }
| take until { |line| $line | empty? }
| split column " "
| get column1
}
def "complete svn add paths" [] {
^svn status --depth files
| lines
| parse "{mode} {file}"
| str trim
| where mode == ?
| get file
}
def "complete svn revert paths" [] {
^svn status --depth files
| lines
| parse "{mode} {file}"
| where mode == M
| str trim
| get file
}
def "complete svn depth" [] { ['empty', 'files', 'immediates', 'infinity'] }
def "complete svn changelists" [] {
^svn status --depth files
| lines
| parse "--- Changelist '{changelist}':"
| get --ignore-errors changelist
}
# Subversion is a tool for version control.
# For additional information, see http://subversion.apache.org/
export extern svn [
subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
--version # to see the program version and RA modules
--quiet # to see just the version number
--verbose # to see dependency versions as well
]
# help (?, h): Describe the usage of this program or its subcommands.
# usage: help [SUBCOMMAND...]
export extern "svn help" [
subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
--verbose(-v) # also show experimental subcommands and options
]
# FIXME: https://github.com/nushell/nushell/issues/5012
# rest parameters do not play well with completions yet
# the `paths` parameter should be `...paths`
# Put new files and directories under version control.
export extern "svn add" [
paths: path@"complete svn add paths" # unversioned PATHs for addition
--targets: path # pass contents of file ARG as additional args
--non-recursive(-N) # obsolete; same as --depth=empty
--depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
--quiet(-q) # print nothing, or only summary information
--force # ignore already versioned paths
--no-ignore # disregard default and svn:ignore and svn:global-ignores property ignores
--auto-props # enable automatic properties
--no-auto-props # disable automatic properties
--parents # add intermediate parents
]
export extern "svn revert" [
paths: path@"complete svn revert paths"
--targets: path # pass contents of file as additional args
--recursive(-R) # descend recursively, same as --depth=infinity
--depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
--quiet(-q) # print nothing, or only summary information
--changelist: string@"complete svn changelists" # operate only on members of changelist ARG
--remove-added # reverting an added item will remove it from disk
]
}
use svn *