Fix: Many little bugs and ps1 management
This commit is contained in:
parent
ab939c1fa4
commit
3e46d7f6c8
11
bin/idmgr
11
bin/idmgr
@ -168,7 +168,7 @@ idm_get ()
|
||||
;;
|
||||
|
||||
id_config)
|
||||
if [ -f "$value" ]; then
|
||||
if [ -f "$IDM_DIR_ID/$value.env" ]; then
|
||||
echo "id=$value"
|
||||
cat $IDM_DIR_ID/$value.env
|
||||
else
|
||||
@ -193,7 +193,9 @@ idm_validate ()
|
||||
[[ "$value" =~ ^[a-zA-Z0-9_-]+$ ]] && return
|
||||
;;
|
||||
id_config)
|
||||
[[ -f "$IDM_DIR_ID/$value.env" ]] && return
|
||||
if [[ -f "$IDM_DIR_ID/$value.env" ]]; then
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
is_enabled)
|
||||
[ ! -z "${SHELL_ID}" ] && return
|
||||
@ -520,7 +522,7 @@ idm_menu_main ()
|
||||
id=$1
|
||||
elif idm_validate id_config ${2-} ; then
|
||||
menu=core
|
||||
action=ls
|
||||
action=$1
|
||||
id=$2
|
||||
shift 2 && opt=${@} || true
|
||||
elif idm_validate id_config ${3-} ; then
|
||||
@ -574,8 +576,7 @@ idm_menu_main ()
|
||||
return $?
|
||||
fi
|
||||
|
||||
idm_log DEBUG "menu=$menu action=$action id=$id opt=$opt"
|
||||
idm_exit 1 "Command not matched"
|
||||
idm_exit 1 "Command not matched: menu=$menu action=$action id=$id opt=$opt"
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ idm_id_enable()
|
||||
|
||||
idm_id_new ()
|
||||
{
|
||||
local id=${1}
|
||||
local id=${2:-$1}
|
||||
|
||||
# Local checks
|
||||
idm_validate id $id || idm_exit 1 "Id '$id' is not valid"
|
||||
@ -123,7 +123,7 @@ idm_id_ls ()
|
||||
# Parse the config
|
||||
echo $(
|
||||
eval "$(idm_get id_config $id)"
|
||||
echo "$active:$id:${common_name-} (${email-})"
|
||||
echo "$active:$id::::${common_name-} (${email-})"
|
||||
)
|
||||
done | column -t -s: -o' ' | idm_log DUMP -
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ IDM_MOD_DEPS="id pass gpg ssh"
|
||||
## Prompt functions
|
||||
##########################################
|
||||
|
||||
SHELL_PS1="${SHELL_PS1:-[\\u@\\h \\W]\\$ }"
|
||||
#SHELL_PS1="${SHELL_PS1:-${PS1}"
|
||||
|
||||
idm_ps1 ()
|
||||
{
|
||||
@ -40,24 +40,19 @@ idm_ps1_help ()
|
||||
idm_ps1_enable ()
|
||||
{
|
||||
local id=${1}
|
||||
id="\[\033[0;34m\]($id)\[\033[00m\]"
|
||||
echo "export PS1=\"$id \${IDM_SHELL_PS1}\""
|
||||
|
||||
# Notes about colors:
|
||||
# \033]00m\] # for shell
|
||||
# \[\033]01;31m\] for ps1
|
||||
|
||||
|
||||
id="\[\033[0;34m\]($id)\[\033[00m\]"
|
||||
PS1="$id ${PS1:-$SHELL_PS1}"
|
||||
echo "export PS1='$PS1'"
|
||||
echo "export SHELL_PS1='$PS1'"
|
||||
}
|
||||
|
||||
idm_ps1_disable ()
|
||||
{
|
||||
local id=${1}
|
||||
PS1=$( sed "s/$id[^a-z]* //" <<<${PS1:-$SHELL_PS1} )
|
||||
PS1='[\u@\h \W]\$ '
|
||||
echo "export PS1='$PS1'"
|
||||
echo "export SHELL_PS1='$PS1'"
|
||||
echo "export PS1=\"\${IDM_SHELL_PS1}\""
|
||||
return
|
||||
}
|
||||
|
||||
idm_ps1_kill () { idm_ps1_disable ${@-}; }
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
export IDM_SHELL_PS1=${IDM_SHELL_PS1:-${PS1-}}
|
||||
IDM_SRC_WORDS=${IDM_SRC_WORDS-}
|
||||
IDM_BIN=${IDM_BIN:-idmgr}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user