Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sudo prompt item #469

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions functions/_tide_item_sudo.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function _tide_item_sudo
# note that calling `sudo -n` resets the sudo timer; as such, this item is disabled by default.
sudo -n true &>/dev/null && _tide_print_item sudo $tide_sudo_icon
end
2 changes: 1 addition & 1 deletion functions/_tide_remove_unusable_items.fish
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function _tide_remove_unusable_items
# Remove tool-specific items for tools the machine doesn't have installed
set -l removed_items
for item in aws crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi python ruby rustc terraform toolbox zig
for item in aws crystal direnv distrobox docker elixir gcloud git go java kubectl nix_shell node php pulumi python ruby rustc sudo terraform toolbox zig
contains $item $tide_left_prompt_items $tide_right_prompt_items || continue

set -l cli_names $item
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/classic.fish
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ tide_status_bg_color 444444
tide_status_bg_color_failure 444444
tide_status_color $_tide_color_dark_green
tide_status_color_failure D70000
tide_sudo_bg_color 444444
tide_sudo_color $_tide_color_gold
tide_terraform_bg_color 444444
tide_terraform_color 844FBA
tide_time_bg_color 444444
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/classic_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ tide_status_bg_color black
tide_status_bg_color_failure black
tide_status_color green
tide_status_color_failure red
tide_sudo_bg_color black
tide_sudo_color bryellow
tide_terraform_bg_color black
tide_terraform_color magenta
tide_time_bg_color black
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/lean.fish
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ tide_status_bg_color normal
tide_status_bg_color_failure normal
tide_status_color $_tide_color_dark_green
tide_status_color_failure D70000
tide_sudo_bg_color normal
tide_sudo_color $_tide_color_gold
tide_terraform_bg_color normal
tide_terraform_color 844FBA
tide_time_bg_color normal
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/lean_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ tide_status_bg_color normal
tide_status_bg_color_failure normal
tide_status_color green
tide_status_color_failure red
tide_sudo_bg_color normal
tide_sudo_color bryellow
tide_terraform_bg_color normal
tide_terraform_color magenta
tide_time_bg_color normal
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/rainbow.fish
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ tide_status_bg_color 2E3436
tide_status_bg_color_failure CC0000
tide_status_color 4E9A06
tide_status_color_failure FFFF00
tide_sudo_bg_color 444444
tide_sudo_color $_tide_color_gold
tide_terraform_bg_color 800080
tide_terraform_color 000000
tide_time_bg_color D3D7CF
Expand Down
2 changes: 2 additions & 0 deletions functions/tide/configure/configs/rainbow_16color.fish
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ tide_status_bg_color black
tide_status_bg_color_failure red
tide_status_color green
tide_status_color_failure bryellow
tide_sudo_bg_color black
tide_sudo_color bryellow
tide_terraform_bg_color magenta
tide_terraform_color black
tide_time_bg_color white
Expand Down
1 change: 1 addition & 0 deletions functions/tide/configure/icons.fish
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tide_rustc_icon 
tide_shlvl_icon 
tide_status_icon ✔
tide_status_icon_failure ✘
tide_sudo_icon 󰌋
tide_terraform_icon
tide_toolbox_icon 
tide_vi_mode_icon_default D
Expand Down
9 changes: 9 additions & 0 deletions tests/_tide_item_sudo.test.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# RUN: %fish %s
_tide_parent_dirs

mock sudo \* "return 1"
_tide_decolor (_tide_item_sudo) # CHECK:

mock sudo \* "return 0"
set -g tide_sudo_icon 󰌋
_tide_decolor (_tide_item_sudo) # CHECK: 󰌋