Unify exec function definition order
This commit is contained in:
parent
397fbe7ad3
commit
43fd8cb13c
@ -159,15 +159,6 @@ def get_data():
|
|||||||
move(tdir + '/root', '/')
|
move(tdir + '/root', '/')
|
||||||
|
|
||||||
|
|
||||||
def exec_bash_with_integration():
|
|
||||||
os.environ['ENV'] = os.path.join(shell_integration_dir, 'bash', 'kitty.bash')
|
|
||||||
os.environ['KITTY_BASH_INJECT'] = '1'
|
|
||||||
if not os.environ.get('HISTFILE'):
|
|
||||||
os.environ['HISTFILE'] = os.path.join(HOME, '.bash_history')
|
|
||||||
os.environ['KITTY_BASH_UNEXPORT_HISTFILE'] = '1'
|
|
||||||
os.execlp(login_shell, os.path.basename('login_shell'), '--posix')
|
|
||||||
|
|
||||||
|
|
||||||
def exec_zsh_with_integration():
|
def exec_zsh_with_integration():
|
||||||
zdotdir = os.environ.get('ZDOTDIR') or ''
|
zdotdir = os.environ.get('ZDOTDIR') or ''
|
||||||
if not zdotdir:
|
if not zdotdir:
|
||||||
@ -192,14 +183,23 @@ def exec_fish_with_integration():
|
|||||||
os.execlp(login_shell, os.path.basename(login_shell), '-l')
|
os.execlp(login_shell, os.path.basename(login_shell), '-l')
|
||||||
|
|
||||||
|
|
||||||
|
def exec_bash_with_integration():
|
||||||
|
os.environ['ENV'] = os.path.join(shell_integration_dir, 'bash', 'kitty.bash')
|
||||||
|
os.environ['KITTY_BASH_INJECT'] = '1'
|
||||||
|
if not os.environ.get('HISTFILE'):
|
||||||
|
os.environ['HISTFILE'] = os.path.join(HOME, '.bash_history')
|
||||||
|
os.environ['KITTY_BASH_UNEXPORT_HISTFILE'] = '1'
|
||||||
|
os.execlp(login_shell, os.path.basename('login_shell'), '--posix')
|
||||||
|
|
||||||
|
|
||||||
def exec_with_shell_integration():
|
def exec_with_shell_integration():
|
||||||
shell_name = os.path.basename(login_shell).lower()
|
shell_name = os.path.basename(login_shell).lower()
|
||||||
if shell_name == 'bash':
|
|
||||||
exec_bash_with_integration()
|
|
||||||
if shell_name == 'zsh':
|
if shell_name == 'zsh':
|
||||||
exec_zsh_with_integration()
|
exec_zsh_with_integration()
|
||||||
if shell_name == 'fish':
|
if shell_name == 'fish':
|
||||||
exec_fish_with_integration()
|
exec_fish_with_integration()
|
||||||
|
if shell_name == 'bash':
|
||||||
|
exec_bash_with_integration()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@ -222,22 +222,22 @@ using_id() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
using_passwd() {
|
using_python() {
|
||||||
if [ -f "/etc/passwd" -a -r "/etc/passwd" ]; then
|
if detect_python; then
|
||||||
output=$(command grep "^$USER:" /etc/passwd 2>/dev/null)
|
output=$(command $python -c "import pwd, os; print(pwd.getpwuid(os.geteuid()).pw_shell)")
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
login_shell=$(echo $output | parse_passwd_record)
|
login_shell=$output
|
||||||
if login_shell_is_ok; then return 0; fi
|
if login_shell_is_ok; then return 0; fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
using_python() {
|
using_passwd() {
|
||||||
if detect_python; then
|
if [ -f "/etc/passwd" -a -r "/etc/passwd" ]; then
|
||||||
output=$(command $python -c "import pwd, os; print(pwd.getpwuid(os.geteuid()).pw_shell)")
|
output=$(command grep "^$USER:" /etc/passwd 2>/dev/null)
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
login_shell=$output
|
login_shell=$(echo $output | parse_passwd_record)
|
||||||
if login_shell_is_ok; then return 0; fi
|
if login_shell_is_ok; then return 0; fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -270,16 +270,6 @@ if [ "$tty_ok" = "n" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec_bash_with_integration() {
|
|
||||||
export ENV="$shell_integration_dir/bash/kitty.bash"
|
|
||||||
export KITTY_BASH_INJECT="1"
|
|
||||||
if [ -z "$HISTFILE" ]; then
|
|
||||||
export HISTFILE="$HOME/.bash_history"
|
|
||||||
export KITTY_BASH_UNEXPORT_HISTFILE="1"
|
|
||||||
fi
|
|
||||||
exec "$login_shell" "--posix"
|
|
||||||
}
|
|
||||||
|
|
||||||
exec_zsh_with_integration() {
|
exec_zsh_with_integration() {
|
||||||
zdotdir="$ZDOTDIR"
|
zdotdir="$ZDOTDIR"
|
||||||
if [ -z "$zdotdir" ]; then
|
if [ -z "$zdotdir" ]; then
|
||||||
@ -305,17 +295,27 @@ exec_fish_with_integration() {
|
|||||||
exec "$login_shell" "-l"
|
exec "$login_shell" "-l"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exec_bash_with_integration() {
|
||||||
|
export ENV="$shell_integration_dir/bash/kitty.bash"
|
||||||
|
export KITTY_BASH_INJECT="1"
|
||||||
|
if [ -z "$HISTFILE" ]; then
|
||||||
|
export HISTFILE="$HOME/.bash_history"
|
||||||
|
export KITTY_BASH_UNEXPORT_HISTFILE="1"
|
||||||
|
fi
|
||||||
|
exec "$login_shell" "--posix"
|
||||||
|
}
|
||||||
|
|
||||||
exec_with_shell_integration() {
|
exec_with_shell_integration() {
|
||||||
case "$shell_name" in
|
case "$shell_name" in
|
||||||
"zsh")
|
"zsh")
|
||||||
exec_zsh_with_integration
|
exec_zsh_with_integration
|
||||||
;;
|
;;
|
||||||
"bash")
|
|
||||||
exec_bash_with_integration
|
|
||||||
;;
|
|
||||||
"fish")
|
"fish")
|
||||||
exec_fish_with_integration
|
exec_fish_with_integration
|
||||||
;;
|
;;
|
||||||
|
"bash")
|
||||||
|
exec_bash_with_integration
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user