mirror of
https://github.com/ChesterYue/ohmyzsh-theme-passion.git
synced 2026-07-21 20:11:03 +00:00
[A] login info
This commit is contained in:
parent
c572dd8b15
commit
b93e9ce4df
1 changed files with 27 additions and 2 deletions
|
|
@ -22,6 +22,31 @@ function real_time() {
|
||||||
echo "${color}${time}${color_reset}";
|
echo "${color}${time}${color_reset}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# login_info
|
||||||
|
function login_info() {
|
||||||
|
local color="%{$fg_no_bold[cyan]%}"; # color in PROMPT need format in %{XXX%} which is not same with echo
|
||||||
|
local ip
|
||||||
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
|
# Linux
|
||||||
|
ip="$(ifconfig | grep ^eth1 -A 1 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | head -1)";
|
||||||
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
# macOS
|
||||||
|
ip="$(ifconfig | grep ^en1 -A 4 | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | head -1)";
|
||||||
|
elif [[ "$OSTYPE" == "cygwin" ]]; then
|
||||||
|
# POSIX compatibility layer and Linux environment emulation for Windows
|
||||||
|
elif [[ "$OSTYPE" == "msys" ]]; then
|
||||||
|
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
|
||||||
|
elif [[ "$OSTYPE" == "win32" ]]; then
|
||||||
|
# I'm not sure this can happen.
|
||||||
|
elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
||||||
|
# ...
|
||||||
|
else
|
||||||
|
# Unknown.
|
||||||
|
fi
|
||||||
|
local color_reset="%{$reset_color%}";
|
||||||
|
echo "${color}[%n@${ip}]${color_reset}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# directory
|
# directory
|
||||||
function directory() {
|
function directory() {
|
||||||
|
|
@ -29,7 +54,7 @@ function directory() {
|
||||||
# REF: https://stackoverflow.com/questions/25944006/bash-current-working-directory-with-replacing-path-to-home-folder
|
# REF: https://stackoverflow.com/questions/25944006/bash-current-working-directory-with-replacing-path-to-home-folder
|
||||||
local directory="${PWD/#$HOME/~}";
|
local directory="${PWD/#$HOME/~}";
|
||||||
local color_reset="%{$reset_color%}";
|
local color_reset="%{$reset_color%}";
|
||||||
echo "${color}${directory}${color_reset}";
|
echo "${color}[${directory}]${color_reset}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -184,4 +209,4 @@ TRAPALRM() {
|
||||||
|
|
||||||
|
|
||||||
# prompt
|
# prompt
|
||||||
PROMPT='$(real_time) $(directory) $(git_status)$(command_status) ';
|
PROMPT='$(real_time) $(login_info) $(directory) $(git_status)$(command_status) ';
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue