From 2e7342f58eff0518b791e9629565de9f253d99f2 Mon Sep 17 00:00:00 2001 From: ericuni Date: Thu, 22 Aug 2024 13:13:32 +0800 Subject: [PATCH 1/6] add starship --- setup.sh | 1 + zsh/starship.toml | 171 ++++++++++++++++++++++++++++++++++++++++++++++ zsh/zshrc | 2 + 3 files changed, 174 insertions(+) create mode 100644 zsh/starship.toml diff --git a/setup.sh b/setup.sh index ea07f4f..fdd5c1a 100755 --- a/setup.sh +++ b/setup.sh @@ -28,6 +28,7 @@ if [[ -L nvim ]]; then rm nvim fi ln -sf $dot/vim/packer nvim +ln -sf $dot/zsh/starship.toml starship.toml p=".docker" [[ ! -d $p ]] && mkdir $p diff --git a/zsh/starship.toml b/zsh/starship.toml new file mode 100644 index 0000000..38c4050 --- /dev/null +++ b/zsh/starship.toml @@ -0,0 +1,171 @@ +format = '$all' + +add_newline = true + +[character] +success_symbol = '[➜](bold green)' # The 'success_symbol' segment is being set to '➜' with the color 'bold green' + +[directory] +read_only = " 󰌾" + +[package] +symbol = "󰏗 " + +[git_branch] +symbol = " " + +[hostname] +ssh_symbol = " " + +[os.symbols] +Alpaquita = " " +Alpine = " " +AlmaLinux = " " +Amazon = " " +Android = " " +Arch = " " +Artix = " " +CentOS = " " +Debian = " " +DragonFly = " " +Emscripten = " " +EndeavourOS = " " +Fedora = " " +FreeBSD = " " +Garuda = "󰛓 " +Gentoo = " " +HardenedBSD = "󰞌 " +Illumos = "󰈸 " +Kali = " " +Linux = " " +Mabox = " " +Macos = " " +Manjaro = " " +Mariner = " " +MidnightBSD = " " +Mint = " " +NetBSD = " " +NixOS = " " +OpenBSD = "󰈺 " +openSUSE = " " +OracleLinux = "󰌷 " +Pop = " " +Raspbian = " " +Redhat = " " +RedHatEnterprise = " " +RockyLinux = " " +Redox = "󰀘 " +Solus = "󰠳 " +SUSE = " " +Ubuntu = " " +Unknown = " " +Void = " " +Windows = "󰍲 " + +[aws] +symbol = " " + +[buf] +symbol = " " + +[c] +symbol = " " + +[conda] +symbol = " " + +[crystal] +symbol = " " + +[dart] +symbol = " " + +[docker_context] +symbol = " " + +[elixir] +symbol = " " + +[elm] +symbol = " " + +[fennel] +symbol = " " + +[fossil_branch] +symbol = " " + +[golang] +symbol = " " + +[guix_shell] +symbol = " " + +[haskell] +symbol = " " + +[haxe] +symbol = " " + +[hg_branch] +symbol = " " + +[java] +symbol = " " + +[julia] +symbol = " " + +[kotlin] +symbol = " " + +[lua] +symbol = " " + +[memory_usage] +symbol = "󰍛 " + +[meson] +symbol = "󰔷 " + +[nim] +symbol = "󰆥 " + +[nix_shell] +symbol = " " + +[nodejs] +symbol = " " + +[ocaml] +symbol = " " + +[perl] +symbol = " " + +[php] +symbol = " " + +[pijul_channel] +symbol = " " + +[python] +symbol = " " + +[rlang] +symbol = "󰟔 " + +[ruby] +symbol = " " + +[rust] +symbol = "󱘗 " + +[scala] +symbol = " " + +[swift] +symbol = " " + +[zig] +symbol = " " diff --git a/zsh/zshrc b/zsh/zshrc index e8ca6e1..bf0cdd4 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -19,6 +19,8 @@ export LANG=en_US.UTF-8 export PS1='%(!.%{$fg[red]%}.%{$fg[green]%})%1~%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} ' export RPROMPT='%n@%m %*' +eval "$(starship init zsh)" + setopt vi setopt NO_HUP setopt rmstarsilent ## supress warning when `rm -rf *` "zsh: sure you want to delete all the files in ... [yn]"? From 63ddd5906101e37138d4f9dac201a912a0deb631 Mon Sep 17 00:00:00 2001 From: ericuni Date: Thu, 22 Aug 2024 14:36:58 +0800 Subject: [PATCH 2/6] less --- zsh/starship.toml | 174 +++++++++++----------------------------------- 1 file changed, 42 insertions(+), 132 deletions(-) diff --git a/zsh/starship.toml b/zsh/starship.toml index 38c4050..178c40c 100644 --- a/zsh/starship.toml +++ b/zsh/starship.toml @@ -1,9 +1,40 @@ -format = '$all' +format = """ +$username\ +$hostname\ +$localip\ +$directory\ +$git_branch\ +$git_commit\ +$git_state\ +$git_metrics\ +$git_status\ +$package\ +$c\ +$golang\ +$python\ +$rust\ +$env_var\ +$crystal\ +$custom\ +$sudo\ +$cmd_duration\ +$line_break\ +$jobs\ +$battery\ +$time\ +$status\ +$os\ +$container\ +$shell\ +$character""" add_newline = true +[username] +style_user = 'green' + [character] -success_symbol = '[➜](bold green)' # The 'success_symbol' segment is being set to '➜' with the color 'bold green' +success_symbol = '[\$](bold green)' # The 'success_symbol' segment is being set to '➜' with the color 'bold green' [directory] read_only = " 󰌾" @@ -17,155 +48,34 @@ symbol = " " [hostname] ssh_symbol = " " +[localip] +disabled = false +style = 'green' + [os.symbols] -Alpaquita = " " -Alpine = " " -AlmaLinux = " " -Amazon = " " -Android = " " -Arch = " " -Artix = " " -CentOS = " " -Debian = " " -DragonFly = " " -Emscripten = " " -EndeavourOS = " " -Fedora = " " -FreeBSD = " " -Garuda = "󰛓 " -Gentoo = " " -HardenedBSD = "󰞌 " -Illumos = "󰈸 " -Kali = " " -Linux = " " -Mabox = " " Macos = " " -Manjaro = " " -Mariner = " " -MidnightBSD = " " -Mint = " " -NetBSD = " " -NixOS = " " -OpenBSD = "󰈺 " -openSUSE = " " -OracleLinux = "󰌷 " -Pop = " " -Raspbian = " " -Redhat = " " -RedHatEnterprise = " " -RockyLinux = " " -Redox = "󰀘 " -Solus = "󰠳 " -SUSE = " " Ubuntu = " " +Debian = " " +Redhat = " " +Linux = " " Unknown = " " -Void = " " Windows = "󰍲 " -[aws] -symbol = " " - -[buf] -symbol = " " +[shell] +disabled = true [c] symbol = " " -[conda] -symbol = " " - -[crystal] -symbol = " " - -[dart] -symbol = " " - -[docker_context] -symbol = " " - -[elixir] -symbol = " " - -[elm] -symbol = " " - -[fennel] -symbol = " " - -[fossil_branch] -symbol = " " - [golang] symbol = " " -[guix_shell] -symbol = " " - -[haskell] -symbol = " " - -[haxe] -symbol = " " - -[hg_branch] -symbol = " " - -[java] -symbol = " " - -[julia] -symbol = " " - -[kotlin] -symbol = " " - -[lua] -symbol = " " - -[memory_usage] -symbol = "󰍛 " - -[meson] -symbol = "󰔷 " - -[nim] -symbol = "󰆥 " - [nix_shell] symbol = " " -[nodejs] -symbol = " " - -[ocaml] -symbol = " " - -[perl] -symbol = " " - -[php] -symbol = " " - -[pijul_channel] -symbol = " " - [python] symbol = " " -[rlang] -symbol = "󰟔 " - -[ruby] -symbol = " " - [rust] symbol = "󱘗 " -[scala] -symbol = " " - -[swift] -symbol = " " - -[zig] -symbol = " " From efa44b2b5d74974e2ed52b7c5ecf56814701679d Mon Sep 17 00:00:00 2001 From: ericuni Date: Thu, 22 Aug 2024 19:27:55 +0800 Subject: [PATCH 3/6] ps1 --- zsh/starship.toml | 63 +++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/zsh/starship.toml b/zsh/starship.toml index 178c40c..548aa13 100644 --- a/zsh/starship.toml +++ b/zsh/starship.toml @@ -1,52 +1,63 @@ format = """ -$username\ -$hostname\ -$localip\ $directory\ $git_branch\ $git_commit\ $git_state\ $git_metrics\ $git_status\ -$package\ -$c\ -$golang\ -$python\ -$rust\ $env_var\ -$crystal\ $custom\ -$sudo\ $cmd_duration\ $line_break\ -$jobs\ -$battery\ $time\ $status\ -$os\ -$container\ -$shell\ $character""" -add_newline = true +right_format = """ +$username\ +$hostname\ +$golang\ +$python\ +$rust\ +$package\ +$c\ +$jobs\ +""" -[username] -style_user = 'green' +add_newline = false [character] -success_symbol = '[\$](bold green)' # The 'success_symbol' segment is being set to '➜' with the color 'bold green' +success_symbol = '[\$](bold green)' # shell prompt [directory] +style = "green" read_only = " 󰌾" - -[package] -symbol = "󰏗 " +truncation_length = 1 # the number of parent folders that the current directory should be truncated to. [git_branch] -symbol = " " +# symbol = " " +symbol = "" +format = '[\($branch\)](bold blue) ' + +[git_metrics] +disabled = false + +# info 与 character 之间是否换行 +[line_break] +disabled = true + +# status of last cmd, i.e. echo $? +[status] +disabled = false + +[username] +style_user = 'green' +format = '$user' [hostname] ssh_symbol = " " +format = '@$hostname ' +ssh_only = false [localip] disabled = false @@ -68,7 +79,8 @@ disabled = true symbol = " " [golang] -symbol = " " +symbol = "" +format = 'Go $version' [nix_shell] symbol = " " @@ -79,3 +91,6 @@ symbol = " " [rust] symbol = "󱘗 " +[package] +symbol = "󰏗 " + From 75505b7a3a374188b3bee07cfd40460b5bc52b4e Mon Sep 17 00:00:00 2001 From: ericuni Date: Thu, 22 Aug 2024 19:35:58 +0800 Subject: [PATCH 4/6] time --- zsh/starship.toml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/zsh/starship.toml b/zsh/starship.toml index 548aa13..b0d3aa5 100644 --- a/zsh/starship.toml +++ b/zsh/starship.toml @@ -7,27 +7,27 @@ $git_metrics\ $git_status\ $env_var\ $custom\ -$cmd_duration\ $line_break\ -$time\ $status\ $character""" right_format = """ $username\ $hostname\ +$cmd_duration\ $golang\ $python\ $rust\ $package\ $c\ $jobs\ +$time\ """ add_newline = false [character] -success_symbol = '[\$](bold green)' # shell prompt +format = '' [directory] style = "green" @@ -39,8 +39,9 @@ truncation_length = 1 # the number of parent folders that the current directory symbol = "" format = '[\($branch\)](bold blue) ' +# +-的行数 [git_metrics] -disabled = false +disabled = true # info 与 character 之间是否换行 [line_break] @@ -80,7 +81,7 @@ symbol = " " [golang] symbol = "" -format = 'Go $version' +format = 'Go$version ' [nix_shell] symbol = " " @@ -94,3 +95,6 @@ symbol = "󱘗 " [package] symbol = "󰏗 " +[time] +disabled = false +format = '$time' From fbc7830c78005f7a1559470088a0ddf4491c9c13 Mon Sep 17 00:00:00 2001 From: "liuqi.victor" Date: Thu, 22 Aug 2024 19:41:28 +0800 Subject: [PATCH 5/6] install starship --- env/linux.sh | 2 +- env/mac.sh | 2 +- zsh/starship.toml | 1 + zsh/zshrc | 11 ++++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/env/linux.sh b/env/linux.sh index b36ab30..5e371d9 100755 --- a/env/linux.sh +++ b/env/linux.sh @@ -109,7 +109,7 @@ cd - # rust install_rust -install_rust_cmds lsd zoxide bat killport joshuto +install_rust_cmds lsd zoxide starship bat killport joshuto install_rust_special_cmd rg ripgrep install_rust_special_cmd fd fd-find install_rust_special_cmd sk skim diff --git a/env/mac.sh b/env/mac.sh index ab5a469..9f358b8 100755 --- a/env/mac.sh +++ b/env/mac.sh @@ -55,7 +55,7 @@ brew install lsd ## need change iterm font brew tap homebrew/cask-fonts && brew install font-hack-nerd-font -brew install zoxide fzf +brew install zoxide fzf starship # brew install mysql diff --git a/zsh/starship.toml b/zsh/starship.toml index b0d3aa5..d8c2840 100644 --- a/zsh/starship.toml +++ b/zsh/starship.toml @@ -54,6 +54,7 @@ disabled = false [username] style_user = 'green' format = '$user' +show_always = true [hostname] ssh_symbol = " " diff --git a/zsh/zshrc b/zsh/zshrc index bf0cdd4..1925f0e 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -16,10 +16,15 @@ fi export TERM=xterm-256color export LANG=en_US.UTF-8 -export PS1='%(!.%{$fg[red]%}.%{$fg[green]%})%1~%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} ' -export RPROMPT='%n@%m %*' -eval "$(starship init zsh)" +which starship >/dev/null +if [[ $? -eq 0 ]]; then + eval "$(starship init zsh)" +else + export PS1='%(!.%{$fg[red]%}.%{$fg[green]%})%1~%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} ' + export RPROMPT='%n@%m %*' +fi + setopt vi setopt NO_HUP From ea93b311900256de4210c1c1a9a5b73172a7bbf9 Mon Sep 17 00:00:00 2001 From: "liuqi.victor" Date: Thu, 22 Aug 2024 20:00:17 +0800 Subject: [PATCH 6/6] add doc --- zsh/starship.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zsh/starship.toml b/zsh/starship.toml index d8c2840..b2a1c4a 100644 --- a/zsh/starship.toml +++ b/zsh/starship.toml @@ -1,3 +1,5 @@ +# doc: https://starship.rs/config/ + format = """ $directory\ $git_branch\ @@ -84,9 +86,6 @@ symbol = " " symbol = "" format = 'Go$version ' -[nix_shell] -symbol = " " - [python] symbol = " "