mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
bash prompt
This commit is contained in:
parent
e1ae304487
commit
24401dfd63
3 changed files with 18 additions and 5 deletions
|
|
@ -1,2 +0,0 @@
|
||||||
''
|
|
||||||
''
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
git = config.modules.user.git;
|
||||||
|
|
||||||
|
in
|
||||||
''
|
''
|
||||||
check_ssh() {
|
check_ssh() {
|
||||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||||
|
|
@ -6,6 +13,7 @@ check_ssh() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
${optionalString git.enable ''
|
||||||
add_icon() {
|
add_icon() {
|
||||||
local icon=$1
|
local icon=$1
|
||||||
if [[ ! $venv_icons =~ $icon ]]; then
|
if [[ ! $venv_icons =~ $icon ]]; then
|
||||||
|
|
@ -82,6 +90,7 @@ check_project() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
''}
|
||||||
|
|
||||||
function set_prompt() {
|
function set_prompt() {
|
||||||
local green_arrow="\[\033[01;32m\]>> "
|
local green_arrow="\[\033[01;32m\]>> "
|
||||||
|
|
@ -89,13 +98,20 @@ function set_prompt() {
|
||||||
local working_dir="\[\033[01;34m\]\w\[\033[00m\]"
|
local working_dir="\[\033[01;34m\]\w\[\033[00m\]"
|
||||||
|
|
||||||
local ssh_PS1
|
local ssh_PS1
|
||||||
|
|
||||||
|
check_ssh
|
||||||
|
${optionalString git.enable ''
|
||||||
local venv_icons
|
local venv_icons
|
||||||
local git_branch_PS1
|
local git_branch_PS1
|
||||||
|
|
||||||
check_ssh
|
|
||||||
check_project
|
check_project
|
||||||
|
''}
|
||||||
|
|
||||||
|
PS1="$ssh_PS1\n$working_dir$green_arrow$white_text"
|
||||||
|
|
||||||
|
${optionalString git.enable ''
|
||||||
PS1="$ssh_PS1\n$working_dir\n$venv_icons$green_arrow$git_branch_PS1$white_text"
|
PS1="$ssh_PS1\n$working_dir\n$venv_icons$green_arrow$git_branch_PS1$white_text"
|
||||||
|
''}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
enableCompletion = true;
|
enableCompletion = true;
|
||||||
|
|
||||||
initExtra = import ./config/prompt.nix;
|
initExtra = import ./config/prompt.nix { inherit lib config; };
|
||||||
profileExtra = import ./config/bashprofile.nix;
|
|
||||||
bashrcExtra = import ./config/bashrc.nix;
|
bashrcExtra = import ./config/bashrc.nix;
|
||||||
shellAliases = import ./config/alias.nix;
|
shellAliases = import ./config/alias.nix;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue