Change color for login when root

This commit is contained in:
Kujiu 2023-09-30 02:18:28 +02:00
parent 0f668f8f2e
commit d425ac2ef8
Signed by: kujiu
GPG key ID: ABBB2CAC6855599F
2 changed files with 8 additions and 10 deletions

View file

@ -176,6 +176,8 @@ def get_styles(background_color: str) -> Dict[Any, str]:
#Special tokens for customized IPython Prompt
Token.IPython.Prompt.Login: NFOX_BG0 + " bg:" + NFOX_CYAN,
Token.IPython.Prompt.Login.Sep: NFOX_CYAN + " bg:" + NFOX_BLUE,
Token.IPython.Prompt.Login.Root: NFOX_BG0 + " bg:" + NFOX_RED,
Token.IPython.Prompt.Login.Root.Sep: NFOX_RED + " bg:" + NFOX_BLUE,
Token.IPython.Prompt.Host: NFOX_BG0 + " bg:" + NFOX_BLUE,
Token.IPython.Prompt.Host.Sep: NFOX_BLUE + " bg:" + NFOX_FG3,
Token.IPython.Prompt.Venv: NFOX_BG0 + " bg:" + NFOX_FG3,

View file

@ -7,7 +7,6 @@ from platform import python_version
import os
import socket
import subprocess
import sys
from typing_extensions import override
from typing import List, Any, Tuple
@ -16,32 +15,26 @@ TOKENS_MODE = {
'V': (
Token.IPython.Prompt.Mode.Visual,
Token.IPython.Prompt.Mode.Visual.Sep,
Token.IPython.Prompt.Mode.Visual.Sep.Root,
),
'I': (
Token.IPython.Prompt.Mode.Insert,
Token.IPython.Prompt.Mode.Insert.Sep,
Token.IPython.Prompt.Mode.Insert.Sep.Root,
),
'N': (
Token.IPython.Prompt.Mode.Nav,
Token.IPython.Prompt.Mode.Nav.Sep,
Token.IPython.Prompt.Mode.Nav.Sep.Root,
),
'R': (
Token.IPython.Prompt.Mode.Replace,
Token.IPython.Prompt.Mode.Replace.Sep,
Token.IPython.Prompt.Mode.Replace.Sep.Root,
),
'r': (
Token.IPython.Prompt.Mode.ReplaceOne,
Token.IPython.Prompt.Mode.ReplaceOne.Sep,
Token.IPython.Prompt.Mode.ReplaceOne.Sep.Root,
),
'E': (
Token.IPython.Prompt.Mode,
Token.IPython.Prompt.Mode.Sep,
Token.IPython.Prompt.Mode.Sep.Root,
)
}
@ -93,6 +86,8 @@ class NightfoxPrompts(Prompts):
login = os.getlogin()
token_cwd = Token.IPython.Prompt.Cwd
token_cwd_sep = Token.IPython.Prompt.Cwd.Sep
token_login = Token.IPython.Prompt.Login
token_login_sep = Token.IPython.Prompt.Login.Sep
token_mode = TOKENS_MODE[vi_mode][0]
token_mode_sep = TOKENS_MODE[vi_mode][1]
token_status = Token.IPython.Prompt.Status
@ -116,11 +111,12 @@ class NightfoxPrompts(Prompts):
if login == 'root':
token_cwd = Token.IPython.Prompt.Cwd.Root
token_cwd_sep = Token.IPython.Prompt.Cwd.Root.Sep
token_mode_sep = TOKENS_MODE[vi_mode][2]
token_login = Token.IPython.Prompt.Login.Root
token_login_sep = Token.IPython.Prompt.Login.Root.Sep
return [
(Token.IPython.Prompt.Login, login),
(Token.IPython.Prompt.Login.Sep, ''),
(token_login, login),
(token_login_sep, ''),
(Token.IPython.Prompt.Host, socket.gethostname()),
(Token.IPython.Prompt.Host.Sep, ''),
(Token.IPython.Prompt.Venv, venv + '' + python_version()),