mirror of
https://github.com/nushell/nushell.git
synced 2025-02-13 00:50:28 +01:00
Default config improvements (#4565)
* Default config improvements * Finish cleanup * Add some comments
This commit is contained in:
parent
52ee1917ba
commit
643c5097d6
@ -211,6 +211,26 @@ impl NuCompleter {
|
|||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
|
|
||||||
for named in &sig.named {
|
for named in &sig.named {
|
||||||
|
if let Some(short) = named.short {
|
||||||
|
let mut named = vec![0; short.len_utf8()];
|
||||||
|
short.encode_utf8(&mut named);
|
||||||
|
named.insert(0, b'-');
|
||||||
|
println!("{:?}", named);
|
||||||
|
if named.starts_with(&prefix) {
|
||||||
|
output.push((
|
||||||
|
reedline::Span {
|
||||||
|
start: new_span.start - offset,
|
||||||
|
end: new_span.end - offset,
|
||||||
|
},
|
||||||
|
String::from_utf8_lossy(&named).to_string(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if named.long.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let mut named = named.long.as_bytes().to_vec();
|
let mut named = named.long.as_bytes().to_vec();
|
||||||
named.insert(0, b'-');
|
named.insert(0, b'-');
|
||||||
named.insert(0, b'-');
|
named.insert(0, b'-');
|
||||||
|
@ -84,7 +84,7 @@ pub(crate) fn read_config_file(
|
|||||||
.expect("Failed to read user input");
|
.expect("Failed to read user input");
|
||||||
|
|
||||||
match answer.to_lowercase().trim() {
|
match answer.to_lowercase().trim() {
|
||||||
"y" => {
|
"y" | "" => {
|
||||||
let mut output = File::create(&config_path).expect("Unable to create file");
|
let mut output = File::create(&config_path).expect("Unable to create file");
|
||||||
let config_file = include_str!("default_config.nu");
|
let config_file = include_str!("default_config.nu");
|
||||||
write!(output, "{}", config_file).expect("Unable to write to config file");
|
write!(output, "{}", config_file).expect("Unable to write to config file");
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
# Nushell Config File
|
# Nushell Config File
|
||||||
|
|
||||||
def create_left_prompt [] {
|
def create_left_prompt [] {
|
||||||
let path_segment = ([
|
let path_segment = ($nu.cwd)
|
||||||
($nu.cwd)
|
|
||||||
(char space)
|
|
||||||
] | str collect)
|
|
||||||
|
|
||||||
$path_segment
|
$path_segment
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_right_prompt [] {
|
def create_right_prompt [] {
|
||||||
let time_segment = ([
|
let time_segment = ([
|
||||||
(date now | date format '%m/%d/%Y %I:%M:%S%.3f')
|
(date now | date format '%m/%d/%Y %r')
|
||||||
] | str collect)
|
] | str collect)
|
||||||
|
|
||||||
$time_segment
|
$time_segment
|
||||||
@ -28,33 +25,102 @@ let-env PROMPT_INDICATOR_VI_INSERT = ": "
|
|||||||
let-env PROMPT_INDICATOR_VI_NORMAL = "〉"
|
let-env PROMPT_INDICATOR_VI_NORMAL = "〉"
|
||||||
let-env PROMPT_MULTILINE_INDICATOR = "::: "
|
let-env PROMPT_MULTILINE_INDICATOR = "::: "
|
||||||
|
|
||||||
|
# Custom completions for external commands (those outside of Nushell)
|
||||||
|
# Each completions has two parts: the form of the external command, including its flags and parameters
|
||||||
|
# and a helper command that knows how to complete values for those flags and parameters
|
||||||
|
#
|
||||||
|
# This is a simplified version of completions for git branches and git remotes
|
||||||
|
def "nu-complete git branches" [] {
|
||||||
|
^git branch | lines | each { |line| $line | str find-replace "\* " "" | str trim }
|
||||||
|
}
|
||||||
|
|
||||||
|
def "nu-complete git remotes" [] {
|
||||||
|
^git remote | lines | each { |line| $line | str trim }
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "git checkout" [
|
||||||
|
branch?: string@"nu-complete git branches" # name of the branch to checkout
|
||||||
|
-b: string # create and checkout a new branch
|
||||||
|
-B: string # create/reset and checkout a branch
|
||||||
|
-l # create reflog for new branch
|
||||||
|
--guess # second guess 'git checkout <no-such-branch>' (default)
|
||||||
|
--overlay # use overlay mode (default)
|
||||||
|
--quiet(-q) # suppress progress reporting
|
||||||
|
--recurse-submodules: string # control recursive updating of submodules
|
||||||
|
--progress # force progress reporting
|
||||||
|
--merge(-m) # perform a 3-way merge with the new branch
|
||||||
|
--conflict: string # conflict style (merge or diff3)
|
||||||
|
--detach(-d) # detach HEAD at named commit
|
||||||
|
--track(-t) # set upstream info for new branch
|
||||||
|
--force(-f) # force checkout (throw away local modifications)
|
||||||
|
--orphan: string # new unparented branch
|
||||||
|
--overwrite-ignore # update ignored files (default)
|
||||||
|
--ignore-other-worktrees # do not check if another worktree is holding the given ref
|
||||||
|
--ours(-2) # checkout our version for unmerged files
|
||||||
|
--theirs(-3) # checkout their version for unmerged files
|
||||||
|
--patch(-p) # select hunks interactively
|
||||||
|
--ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only
|
||||||
|
--pathspec-from-file: string # read pathspec from file
|
||||||
|
]
|
||||||
|
|
||||||
|
extern "git push" [
|
||||||
|
remote?: string@"nu-complete git remotes", # the name of the remote
|
||||||
|
refspec?: string@"nu-complete git branches"# the branch / refspec
|
||||||
|
--verbose(-v) # be more verbose
|
||||||
|
--quiet(-q) # be more quiet
|
||||||
|
--repo: string # repository
|
||||||
|
--all # push all refs
|
||||||
|
--mirror # mirror all refs
|
||||||
|
--delete(-d) # delete refs
|
||||||
|
--tags # push tags (can't be used with --all or --mirror)
|
||||||
|
--dry-run(-n) # dry run
|
||||||
|
--porcelain # machine-readable output
|
||||||
|
--force(-f) # force updates
|
||||||
|
--force-with-lease: string # require old value of ref to be at this value
|
||||||
|
--recurse-submodules: string # control recursive pushing of submodules
|
||||||
|
--thin # use thin pack
|
||||||
|
--receive-pack: string # receive pack program
|
||||||
|
--exec: string # receive pack program
|
||||||
|
--set-upstream(-u) # set upstream for git pull/status
|
||||||
|
--progress # force progress reporting
|
||||||
|
--prune # prune locally removed refs
|
||||||
|
--no-verify # bypass pre-push hook
|
||||||
|
--follow-tags # push missing but relevant tags
|
||||||
|
--signed: string # GPG sign the push
|
||||||
|
--atomic # request atomic transaction on remote side
|
||||||
|
--push-option(-o): string # option to transmit
|
||||||
|
--ipv4(-4) # use IPv4 addresses only
|
||||||
|
--ipv6(-6) # use IPv6 addresses only
|
||||||
|
]
|
||||||
|
|
||||||
|
# The default config record. This is where much of your global configuration is setup.
|
||||||
let $config = {
|
let $config = {
|
||||||
filesize_metric: $true
|
filesize_metric: $false
|
||||||
table_mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
|
table_mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
|
||||||
use_ls_colors: $true
|
use_ls_colors: $true
|
||||||
rm_always_trash: $false
|
rm_always_trash: $false
|
||||||
color_config: {
|
color_config: {
|
||||||
separator: yd
|
separator: white
|
||||||
leading_trailing_space_bg: white
|
leading_trailing_space_bg: white
|
||||||
header: cb
|
header: green_bold
|
||||||
date: pu
|
date: white
|
||||||
filesize: ub
|
filesize: white
|
||||||
row_index: yb
|
row_index: green_bold
|
||||||
hints: dark_gray
|
hints: dark_gray
|
||||||
bool: red
|
bool: white
|
||||||
int: green
|
int: white
|
||||||
duration: red
|
duration: white
|
||||||
range: red
|
range: white
|
||||||
float: red
|
float: white
|
||||||
string: red
|
string: white
|
||||||
nothing: red
|
nothing: white
|
||||||
binary: red
|
binary: white
|
||||||
cellpath: red
|
cellpath: white
|
||||||
}
|
}
|
||||||
use_grid_icons: $true
|
use_grid_icons: $true
|
||||||
footer_mode: always #always, never, number_of_rows, auto
|
footer_mode: always # always, never, number_of_rows, auto
|
||||||
quick_completions: $false
|
quick_completions: $false # set this to $true to auto-select completions when only one remains
|
||||||
animate_prompt: $false
|
animate_prompt: $false # redraw the prompt every second
|
||||||
float_precision: 2
|
float_precision: 2
|
||||||
use_ansi_coloring: $true
|
use_ansi_coloring: $true
|
||||||
filesize_format: "b" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto
|
filesize_format: "b" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto
|
||||||
@ -70,7 +136,7 @@ let $config = {
|
|||||||
columns: 4
|
columns: 4
|
||||||
col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
|
col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
|
||||||
col_padding: 2
|
col_padding: 2
|
||||||
text_style: red
|
text_style: green
|
||||||
selected_text_style: green_reverse
|
selected_text_style: green_reverse
|
||||||
marker: "| "
|
marker: "| "
|
||||||
}
|
}
|
||||||
@ -82,12 +148,12 @@ let $config = {
|
|||||||
marker: "? "
|
marker: "? "
|
||||||
}
|
}
|
||||||
keybindings: [
|
keybindings: [
|
||||||
{
|
{
|
||||||
name: completion
|
name: completion
|
||||||
modifier: control
|
modifier: control
|
||||||
keycode: char_t
|
keycode: char_t
|
||||||
mode: vi_insert # emacs vi_normal vi_insert
|
mode: vi_insert # emacs vi_normal vi_insert
|
||||||
event: { send: menu name: context_menu }
|
event: { send: menu name: context_menu }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user