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

feat: Display npmrc profile #332

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Fully **customizable** (colors, symbols and features):
- Detect when running in a container ;
- Shorten _current folder_ component in prompt and window title 🏴;
- Truncate _current folder_ component in prompt and window title 🏴;
- Display [_npmrc_](https://github.com/deoxxa/npmrc) profile name when activated 🏴 ;

🏴: Enabled or disabled via a [feature flag](#-features-flags).

Expand Down Expand Up @@ -95,6 +96,7 @@ set --universal pure_color_system_time pure_color_mute
| **`pure_symbol_ssh_prefix`** | | Prefix when being connected to SSH session (default: [undefined][to-set]) |
| **`pure_symbol_title_bar_separator`** | `-` | Separator in terminal's windows title. |
| **`pure_symbol_virtualenv_prefix`** | | Prefix when a Python virtual env is activated (default: [undefined][to-set]) |
| **`pure_symbol_npmrc_prefix`** | | Prefix when a npmrc is activated (default: [undefined][to-set]) |

> :information_source: Need [safer `git` symbols](https://github.com/sindresorhus/pure/wiki/Customizations,-hacks-and-tweaks#safer-symbols)?

Expand All @@ -107,6 +109,7 @@ set --universal pure_color_system_time pure_color_mute
| **`pure_enable_container_detection`** | `true` | `false`: Do not check if run in container (e.g. `docker`, `podman`, `LXC`/`LXD`, etc.).<br/>:warning: Detection is a bit [tricky across OSes][container-detection]. |
| **`pure_enable_git`** | `true` | Show info about Git repository. |
| **`pure_enable_k8s`** | `false` | `true`: shows `kubernetes` context and namespace. |
| **`pure_enable_npmrc`** | `false` | `true`: shows [npmrc](https://github.com/deoxxa/npmrc) profile |
| **`pure_enable_single_line_prompt`** | `false` | `true`: Compact prompt as a single line |
| **`pure_enable_virtualenv`** | `true` | Show virtual env name (based on `VIRTUAL_ENV` or `CONDA_DEFAULT_ENV`). |
| **`pure_reverse_prompt_symbol_in_vimode`** | `true` | `true`: `❮` indicate a non-insert mode.<br/>`false`: indicate vi mode with `[I]`, `[N]`, `[V]`. |
Expand All @@ -118,8 +121,8 @@ set --universal pure_color_system_time pure_color_mute
| **`pure_show_subsecond_command_duration`** | `false` | Show subsecond (ex. 1.5s) in command duration. |
| **`pure_show_system_time`** | `false` | `true`: shows system time before the prompt symbol (as `%H:%M:%S`). |
| **`pure_threshold_command_duration`** | `5` | Show command duration when above this value (seconds). |
| **`pure_truncate_prompt_current_directory_keeps`** | `0` | Truncate working directory path in prompt, but keeps the last to `n` components (`0` full path in current directory) |
| **`pure_truncate_window_title_current_directory_keeps`** | `0` | Truncate working directory path in window title, but keeps the last to `n` components (`0` full path in window title) |
| **`pure_truncate_prompt_current_directory_keeps`** | `0` | Truncate working directory path in prompt, but keeps the last to `n` components (`0` full path in current directory) |
| **`pure_truncate_window_title_current_directory_keeps`** | `0` | Truncate working directory path in window title, but keeps the last to `n` components (`0` full path in window title) |

### 🎨 Colours

Expand Down
5 changes: 5 additions & 0 deletions conf.d/pure.fish
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ _pure_set_default pure_symbol_k8s_prefix "☸" # ☸️
_pure_set_default pure_color_k8s_prefix pure_color_info
_pure_set_default pure_color_k8s_context pure_color_success
_pure_set_default pure_color_k8s_namespace pure_color_primary

# Show npmrc profile (https://github.com/deoxxa/npmrc)
_pure_set_default pure_enable_npmrc false
_pure_set_default pure_symbol_npmrc_prefix "" # 
_pure_set_default pure_color_npmrc pure_color_danger
12 changes: 12 additions & 0 deletions functions/_pure_prompt_npmrc.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function _pure_prompt_npmrc --description "Display npmrc profile"
if set --query pure_enable_npmrc; and test "$pure_enable_npmrc" = true
set --local npmrc ''
set --local npmrc_color (_pure_set_color $pure_color_npmrc)
if test -e "$HOME/.npmrc"
set npmrc (readlink $HOME/.npmrc | cut -d '/' -f 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readlink has no output when $HOME/.npmrc is a regular file and not a symlink. You don't need to resolve the link just to show the basename.

Suggested change
set npmrc (readlink $HOME/.npmrc | cut -d '/' -f 5)
set npmrc (basename $HOME/.npmrc)

end
if test -n $npmrc
echo "$pure_symbol_npmrc_prefix $npmrc_color$npmrc"
end
end
end
Loading