diff --git a/home/common/bash.nix b/home/common/bash.nix new file mode 100644 index 00000000..1936dd75 --- /dev/null +++ b/home/common/bash.nix @@ -0,0 +1,18 @@ +{...}: { + programs.bash = { + enable = true; + enableCompletion = true; + bashrcExtra = '' + export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin" + ''; + + shellAliases = { + k = "kubectl"; + vim = "nvim"; + + urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'"; + urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'"; + httpproxy = "export https_proxy=http://127.0.0.1:7890; export http_proxy=http://127.0.0.1:7890;"; + }; + }; +} \ No newline at end of file diff --git a/home/common/core.nix b/home/common/core.nix index 337154b8..19c7cdef 100644 --- a/home/common/core.nix +++ b/home/common/core.nix @@ -77,22 +77,4 @@ enableBashIntegration = true; }; }; - - programs.bash = { - enable = true; - enableCompletion = true; - bashrcExtra = '' - export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin" - ''; - }; - - - home.shellAliases = { - k = "kubectl"; - vim = "nvim"; - - urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'"; - urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'"; - httpproxy = "export https_proxy=http://127.0.0.1:7890; export http_proxy=http://127.0.0.1:7890;"; - }; } \ No newline at end of file diff --git a/home/common/default.nix b/home/common/default.nix index 51268a45..5144980d 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -2,6 +2,7 @@ { imports = [ ./nushell + ./bash.nix ./core.nix ./development.nix diff --git a/home/common/nushell/config.nu b/home/common/nushell/config.nu new file mode 100644 index 00000000..4f4a50ad --- /dev/null +++ b/home/common/nushell/config.nu @@ -0,0 +1,50 @@ +# Nushell Config File +# +# version = 0.81.1 + +# The default config record. This is where much of your global configuration is setup. +let-env config = { + # true or false to enable or disable the welcome banner at startup + show_banner: false + + 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 + show_empty: true # show 'empty list' and 'empty record' placeholders for command output + trim: { + methodology: wrapping # wrapping or truncating + wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology + truncating_suffix: "..." # A suffix used by the 'truncating' methodology + } + } + + completions: { + case_sensitive: false # set to true to enable case-sensitive completions + quick: true # set this to false to prevent auto-selecting completions when only one remains + partial: true # set this to false to prevent partial filling of the prompt + algorithm: "prefix" # prefix or fuzzy + external: { + enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow + max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options + completer: null # check 'carapace_completer' above as an example + } + } + filesize: { + metric: true # 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, zb, zib, auto + } + cursor_shape: { + emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line (line is the default) + vi_insert: block # block, underscore, line , blink_block, blink_underscore, blink_line (block is the default) + vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line (underscore is the default) + } + use_grid_icons: true + footer_mode: "25" # always, never, number_of_rows, auto + float_precision: 2 # the precision for displaying floats in tables + # buffer_editor: "emacs" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + use_ansi_coloring: true + bracketed_paste: true # enable bracketed paste, currently useless on windows + edit_mode: emacs # emacs, vi + shell_integration: true # enables terminal markers and a workaround to arrow keys stop working issue + 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. +} \ No newline at end of file diff --git a/home/common/nushell/default.nix b/home/common/nushell/default.nix index 64142520..40488ea0 100644 --- a/home/common/nushell/default.nix +++ b/home/common/nushell/default.nix @@ -1,7 +1,21 @@ -{ +{...}: { programs.nushell = { enable = true; - # configFile.source = ./config.nu; + configFile.source = ./config.nu; + + # home-manager will merge the cotent in `environmentVariables` with the `envFile.source` + # but basically, I set all environment variables via the shell-independent way, so I don't need to use those two options + # # envFile.source = ./env.nu; + # environmentVariables = { FOO="bar"; }; + + shellAliases = { + k = "kubectl"; + vim = "nvim"; + + urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'"; + urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'"; + httpproxy = "let-env https_proxy = http://127.0.0.1:7890; let-env http_proxy = http://127.0.0.1:7890;"; + }; }; } \ No newline at end of file diff --git a/modules/nixos/core-desktop.nix b/modules/nixos/core-desktop.nix index 9f3f1e95..3e9a61ba 100644 --- a/modules/nixos/core-desktop.nix +++ b/modules/nixos/core-desktop.nix @@ -241,6 +241,14 @@ ]; }; + # add user's shell into /etc/shells + environment.shells = with pkgs; [ + bash + nushell + ]; + # set user's default shell system-wide + users.defaultUserShell = pkgs.nushell; + # for power management services.upower.enable = true; } \ No newline at end of file