diff --git a/modules/terminal-life/bash/default.nix b/modules/terminal-life/bash/default.nix new file mode 100644 index 00000000..05ea4ecc --- /dev/null +++ b/modules/terminal-life/bash/default.nix @@ -0,0 +1,71 @@ +{ + config, + pkgs, + self, + ... +}: let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in { + enable = true; + + historyControl = ["ignorespace"]; + + # Run when initializing a login shell + profileExtra = '' + [ "$(tty)" = "/dev/tty1" ] && exec ${pkgs.sway-service}/bin/sway-service + ''; + + # Run when initializing an interactive shell + initExtra = '' + # If a command is not found, show me where it is + source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh + + # Helps you navigate directories faster + # https://github.com/gsamokovarov/jump + eval "$(${pkgs.jump}/bin/jump shell --bind=z)" + + eval "$(${pkgs.direnv}/bin/direnv hook bash)" + + # Syntax highlighting, auto suggestions, vim modes, etc. + # https://github.com/akinomyoga/ble.sh/wiki/Manual-A1-Installation#user-content-nixpkgs + source "$(blesh-share)" --attach=none + [[ ''${BLE_VERSION-} ]] && ble-attach + # ctrl + space to accept autocomplete suggestion + ble-bind -m 'auto_complete' -f 'C-@' 'auto_complete/insert-on-end' + # Meta (Alt) + Backspace to delete a word + ble-bind -m 'emacs' -f 'M-C-?' 'kill-backward-cword' + # Meta (Alt) + p to jump one word backwards + ble-bind -m 'emacs' -f M-p '@nomarked backward-cword' + # Meta (Alt) + n to jump one word forwards + ble-bind -m 'emacs' -f M-n '@nomarked forward-cword' + # Arrow up and Ctrl + p searches history for entered input + ble-bind -f up 'history-search-backward hide-status:immediate-accept:empty=emulate-readline:point=end' + ble-bind -f C-p 'history-search-backward hide-status:immediate-accept:empty=emulate-readline:point=end' + # Arrow down and Ctrl + n searches history for entered input + ble-bind -f down 'history-search-forward hide-status:immediate-accept:empty=emulate-readline:point=end' + ble-bind -f C-n 'history-search-forward hide-status:immediate-accept:empty=emulate-readline:point=end' + + bleopt filename_ls_colors="$LS_COLORS" + + source ${config.age.secrets.environment-secrets.path} + ''; + + shellAliases = { + nano = "nvim"; + vi = "nvim"; + vim = "nvim"; + mutt = "neomutt"; + ls = "exa"; + la = "exa --group-directories-first -lag"; + fm = "vifm ."; + vifm = "vifm ."; + wget = "wget --hsts-file=$XDG_CACHE_HOME/wget-hsts"; + irssi = "irssi --config=$XDG_CONFIG_HOME/irssi/config --home=$XDG_DATA_HOME/irssi"; + drone = "DRONE_TOKEN=$(secret-tool lookup drone token) drone"; + no = "manix \"\" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview=\"manix '{}'\" | xargs manix"; + # fix nixos-option + nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat"; + myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; + }; +} diff --git a/modules/terminal-life/default.nix b/modules/terminal-life/default.nix index 3b58243f..a47c4d2b 100644 --- a/modules/terminal-life/default.nix +++ b/modules/terminal-life/default.nix @@ -24,27 +24,29 @@ in { config = mkIf cfg.enable { programs.command-not-found.enable = false; - # Needed to get zsh completion for system packages (e.g. systemd). - environment.pathsToLink = ["/share/zsh"]; - - environment.shells = with pkgs; [ - zsh - ]; - environment.systemPackages = with pkgs; [ screen ]; + # Starship is a fast and featureful shell prompt + # starship.toml has sane defaults that can be changed there + programs.starship = { + enable = true; + settings = import ./starship.toml.nix; + }; + home-manager = with pkgs; pkgs.lib.setAttrByPath ["users" psCfg.user.name] { home.packages = [ ack asciinema bat + blesh exa fd gh glow + jump nnn powerline silver-searcher @@ -52,18 +54,18 @@ in { watson ]; - programs.neovim = import ./nvim { + programs.bash = import ./bash { inherit config; inherit pkgs; + inherit self; }; programs.fzf = import ./fzf { inherit config; inherit pkgs; }; - programs.zsh = import ./zsh { + programs.neovim = import ./nvim { inherit config; inherit pkgs; - inherit self; }; }; }; diff --git a/modules/terminal-life/fzf/default.nix b/modules/terminal-life/fzf/default.nix index 0cc6fd94..372e768d 100644 --- a/modules/terminal-life/fzf/default.nix +++ b/modules/terminal-life/fzf/default.nix @@ -10,5 +10,5 @@ "--color=fg:#d3d1d4,header:#7accd7,info:#e5c463,pointer:#ef9062" "--color=marker:#ef9062,fg+:#303030,prompt:#e5c463,hl+:#7accd7" ]; - enableZshIntegration = true; + enableBashIntegration = true; } diff --git a/modules/terminal-life/starship.toml b/modules/terminal-life/starship.toml new file mode 100644 index 00000000..1ef9ab70 --- /dev/null +++ b/modules/terminal-life/starship.toml @@ -0,0 +1,128 @@ +format = """ +[](#9A348E)\ +$character \ +[](bg:#DA627D fg:#9A348E)\ +$directory\ +[](fg:#DA627D bg:#FCA17D)\ +$git_branch\ +$git_status\ +[](fg:#FCA17D bg:#86BBD8)\ +$c\ +$deno\ +$golang\ +$haskell\ +$nix_shell\ +$nodejs\ +$php\ +$python\ +$ruby\ +$rust\ +$terraform\ +[](fg:#86BBD8 bg:#06969A)\ +$docker_context\ +[](fg:#06969A bg:#33658A)\ +$container \ +[](fg:#06969A bg:#33658A)\ +$time\ +[ ](fg:#33658A)\ +""" + +# Disable the blank line at the start of the prompt +# add_newline = false + +# You can also replace your username with a neat symbol like  to save some space +#[username] +#show_always = true +#style_user = "bg:#9A348E" +#style_root = "bg:#9A348E" +#format = '[$user ]($style)' +[character] +success_symbol = "[❯](bold purple)" +vicmd_symbol = "[❮](bold purple)" + +[directory] +style = "bg:#DA627D" +format = "[ $path ]($style)" +truncation_length = 3 +truncation_symbol = "…/" + +# Here is how you can shorten some long paths by text replacement +# similar to mapped_locations in Oh My Posh: +[directory.substitutions] +"Documents" = " " +"Downloads" = " " +"Music" = " " +"Pictures" = " " +# Keep in mind that the order matters. For example: +# "Important Documents" = "  " +# will not be replaced, because "Documents" was already substituted before. +# So either put "Important Documents" before "Documents" or use the substituted version: +# "Important  " = "  " + +[c] +symbol = " " +style = "bg:#86BBD8" +format = '[ $symbol ($version) ]($style)' + +[container] + +[custom] + +[docker_context] +symbol = " " +style = "bg:#06969A" +format = '[ $symbol $context ]($style) $path' + +[deno] + +[git_branch] +symbol = "" +style = "bg:#FCA17D" +format = '[ $symbol $branch ]($style)' + +[git_status] +style = "bg:#FCA17D" +format = '[$all_status$ahead_behind ]($style)' + +[golang] +symbol = " " +style = "bg:#86BBD8" +format = '[ $symbol ($version) ]($style)' + +[haskell] +symbol = " " +style = "bg:#86BBD8" +format = '[ $symbol ($version) ]($style)' + +[nix_shell] +format = '[$symbol$state]($style) ' +symbol = " " +pure_msg = "λ" +impure_msg = "⎔" + +[nodejs] +symbol = "" +style = "bg:#86BBD8" +format = '[ $symbol ($version) ]($style)' + +[php] +symbol = " " + +[python] +symbol = " " + +[ruby] +symbol = " " + +[rust] +symbol = "" +style = "bg:#86BBD8" +format = '[ $symbol ($version) ]($style)' + +[terraform] + +[time] +disabled = false +time_format = "%R" # Hour:Minute Format +style = "bg:#33658A" +format = '[ ♥ $time ]($style)' diff --git a/modules/terminal-life/starship.toml.nix b/modules/terminal-life/starship.toml.nix new file mode 100644 index 00000000..ab6dfa7f --- /dev/null +++ b/modules/terminal-life/starship.toml.nix @@ -0,0 +1,159 @@ +{ + format = "$directory($git_branch$git_commit$git_state$git_status)($c$deno$golang$haskell$nix_shell$nodejs$php$python$ruby$rust$terraform[](fg:#86BBD8 bg:#06969A))($docker_context[](fg:#06969A))($container)$fill(\${custom.triton})[ ](fg:#F85E84)$line_break$character"; + + # Disable the blank line at the start of the prompt + add_newline = false; + + # You can also replace your username with a neat symbol like  to save some space + #username = { + # show_always = true; + # style_user = "bg:#9A348E"; + # style_root = "bg:#9A348E"; + # format = ''[$user ]($style)''; + #}; + character = { + success_symbol = "[❯](bold purple)"; + error_symbol = "[✗](#ff4b00)"; + vicmd_symbol = "[❮](bold purple)"; + }; + + fill = { + symbol = "-"; + style = "bold green"; + }; + + directory = { + style = "#F85E84"; + truncate_to_repo = false; + fish_style_pwd_dir_length = 1; + truncation_symbol = "…/"; + format = "[](fg:black bg:#F85E84)[$path[$read_only](bg:$style fg:black)](bg:$style fg:black)[](fg:$style)"; + read_only = " "; + }; + + # Here is how you can shorten some long paths by text replacement + # similar to mapped_locations in Oh My Posh: + directory.substitutions = { + "Documents" = " "; + "Downloads" = " "; + "Music" = " "; + "Pictures" = " "; + }; + # Keep in mind that the order matters. For example: + # "Important Documents" = "  " + # will not be replaced, because "Documents" was already substituted before. + # So either put "Important Documents" before "Documents" or use the substituted version: + # "Important  " = "  " + + c = { + symbol = " "; + style = "bg:#86BBD8"; + format = ''[ $symbol ($version) ]($style)''; + }; + + #container = {}; + + custom = { + triton = { + command = "echo $TRITON_PROFILE"; + when = "test $TRITON_PROFILE"; + format = "[✚ ](fg:#F85E84 bg:#1A181A)[$output](fg:#F85E84 bg:#1A181A)"; + description = "The current triton profile"; + }; + }; + + docker_context = { + symbol = " "; + style = "bg:#06969A"; + format = ''[ $symbol $context ]($style) $path''; + }; + + #deno = {}; + + git_branch = { + style = "#E5C463"; + format = "[](fg:black bg:$style)[ $symbol$branch](fg:black bg:$style)[](fg:$style)"; + }; + + git_commit = { + style = "#E5C463"; + # ^H is the literal backspace character which renders to \b in the final + # starship config TOML, produced in insert mode via ctrl+v then ctrl+h. + # We use the literal character, because escaping a single \ doesn't work + # with pkgs.formats.toml, see: https://github.com/NixOS/nixpkgs/issues/97310 and + # https://jdhao.github.io/2020/10/07/nvim_insert_unicode_char/ + format = "[ ](bg:$style)[\\($hash$tag\\)](fg:black bg:$style)[](fg:$style)"; + }; + + git_state = { + style = "#E5C463"; + format = "[ ](bg:$style)[ \\($state( $progress_current/$progress_total)\\)](fg:black bg:$style)[](fg:$style)"; + }; + + git_status = { + style = "#E5C463"; + format = "([ ](bg:$style fg:black)$conflicted$staged$modified$renamed$deleted$untracked$stashed$ahead_behind[](fg:$style))"; + conflicted = "[ ](bold fg:88 bg:#E5C463)[  \${count} ](fg:black bg:#E5C463)"; + staged = "[ $count ](fg:black bg:#E5C463)"; + modified = "[ \${count} ](fg:black bg:#E5C463)"; + renamed = "[ \${count} ](fg:black bg:#E5C463)"; + deleted = "[ \${count} ](fg:black bg:#E5C463)"; + untracked = "[?\${count} ](fg:black bg:#E5C463)"; + stashed = "[ \${count} ](fg:black bg:#E5C463)"; + ahead = "[ \${count} ](fg:#523333 bg:#E5C463)"; + behind = "[ \${count} ](fg:black bg:#E5C463)"; + diverged = "[ ](fg:88 bg:#E5C463)[ נּ ](fg:black bg:#E5C463)[ \${ahead_count} ](fg:black bg:#E5C463)[ \${behind_count} ](fg:black bg:#E5C463)"; + }; + + golang = { + symbol = " "; + style = "bg:#86BBD8"; + format = ''[ $symbol ($version) ]($style)''; + }; + + haskell = { + symbol = " "; + style = "bg:#86BBD8"; + format = ''[ $symbol ($version) ]($style)''; + }; + + nix_shell = { + format = ''[$symbol$state]($style) ''; + symbol = " "; + pure_msg = "λ"; + impure_msg = "⎔"; + }; + + nodejs = { + symbol = ""; + style = "bg:#86BBD8"; + format = ''[ $symbol ($version) ]($style)''; + }; + + php = { + symbol = " "; + }; + + python = { + symbol = " "; + }; + + ruby = { + symbol = " "; + }; + + rust = { + symbol = ""; + style = "bg:#86BBD8"; + format = ''[ $symbol ($version) ]($style)''; + }; + + #terraform = {}; + + time = { + disabled = false; + time_format = "%R"; # Hour:Minute Format + style = "bg:#33658A"; + format = ''[ ♥ $time ]($style)''; + }; +} diff --git a/overlays/blesh.nix b/overlays/blesh.nix new file mode 100644 index 00000000..01874da8 --- /dev/null +++ b/overlays/blesh.nix @@ -0,0 +1,13 @@ +final: prev: { + blesh = prev.blesh.overrideAttrs (oldAttrs: rec { + version = "unstable-2022-12-15"; + src = prev.fetchFromGitHub { + owner = "akinomyoga"; + repo = "ble.sh"; + rev = "32277dae20f004c3a65aeb3adae881b8b8e0318f"; + hash = "sha256-qh5z0rkDOKhgi4/LQX2WHShzqwlOUpe+CuJArEmuKMo="; + fetchSubmodules = true; + leaveDotGit = true; + }; + }); +} diff --git a/pkgs/sway-launcher.nix b/pkgs/sway-launcher.nix index aed2cd1e..1ace27b5 100644 --- a/pkgs/sway-launcher.nix +++ b/pkgs/sway-launcher.nix @@ -1,7 +1,6 @@ self: with self; '' - #!/usr/bin/env zsh - # terminal application launcher for sway, using fzf + #!/usr/bin/env bash # original command: # Based on: https://github.com/swaywm/sway/issues/1367 # bindsym $altkey+space exec termite --name=launcher -e \ diff --git a/profiles/base-user/default.nix b/profiles/base-user/default.nix index 92e297d0..a2c82d97 100644 --- a/profiles/base-user/default.nix +++ b/profiles/base-user/default.nix @@ -31,7 +31,6 @@ in { if psCfg.user.password != null then psCfg.user.password else ""; - shell = pkgs.zsh; openssh.authorizedKeys.keys = if psCfg.user.publicKeys != null then psCfg.user.publicKeys diff --git a/profiles/base-user/home.nix b/profiles/base-user/home.nix index 9c964515..3d801baa 100644 --- a/profiles/base-user/home.nix +++ b/profiles/base-user/home.nix @@ -26,7 +26,6 @@ in { fonts.fontconfig.enable = mkForce true; programs.dircolors.enable = true; - programs.dircolors.enableZshIntegration = true; home.file."xinitrc".source = ./.xinitrc;