diff --git a/README.md b/README.md index 8547ae1..9735bb4 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,10 @@ Type `fancygit -h` to see all available feature switchers on **"FEATURE SWITCHER | fancygit --disable-host-name | Hide host name. | fancygit --enable-user-symbol | Show user symbol. | fancygit --disable-user-symbol | Hide user symbol. +| fancygit --enable-term-title-host | Enables setting the hostname in the terminal title bar. +| fancygit --disable-term-title-host | Disables setting the hostname in the terminal title bar. +| fancygit --enable-term-title-path | Enables setting the path in the terminal title bar. +| fancygit --disable-term-title-path | Disables setting the path in the terminal title bar. | fancygit --set-user-name {name} | Set the user name. | fancygit --unset-user-name | Restore the user name to default. | fancygit --set-host-name {name} | Set the host name. diff --git a/commands-handler.sh b/commands-handler.sh index 1e0c733..c2ae806 100755 --- a/commands-handler.sh +++ b/commands-handler.sh @@ -42,6 +42,10 @@ case "$1" in "--disable-bold-prompt") fancygit_config_save "bold_prompt" "false";; "--enable-host-name") fancygit_config_save "show_host_prompt" "true";; "--disable-host-name") fancygit_config_save "show_host_prompt" "false";; + "--enable-term-title-host") fancygit_config_save "set_term_title_host" "true";; + "--disable-term-title-host") fancygit_config_save "set_term_title_host" "false";; + "--enable-term-title-path") fancygit_config_save "set_term_title_path" "true";; + "--disable-term-title-path") fancygit_config_save "set_term_title_path" "false";; "--enable-user-symbol") fancygit_config_save "show_user_symbol_prompt" "true";; "--disable-user-symbol") fancygit_config_save "show_user_symbol_prompt" "false";; diff --git a/fancygit-completion b/fancygit-completion index a78c965..a067dd4 100644 --- a/fancygit-completion +++ b/fancygit-completion @@ -31,6 +31,10 @@ _fancygit() { --disable-host-name \ --enable-user-symbol \ --disable-user-symbol \ + --enable-term-title-host \ + --disable-term-title-host \ + --enable-term-title-path \ + --disable-term-title-path \ --set-user-name \ --unset-user-name \ --set-host-name \ diff --git a/help.sh b/help.sh index 211b308..fe474cc 100644 --- a/help.sh +++ b/help.sh @@ -37,6 +37,10 @@ FEATURE SWITCHER COMMANDS: fancygit --disable-bold-prompt Show regular prompt font. fancygit --enable-host-name Show host name. (It works for human theme only) fancygit --disable-host-name Hide host name. (It works for human theme only) + fancygit --enable-term-title-host Enables setting the hostname in the terminal title bar. + fancygit --disable-term-title-host Disables setting the hostname in the terminal title bar. + fancygit --enable-term-title-path Enables setting the path in the terminal title bar. + fancygit --disable-term-title-path Disables setting the path in the terminal title bar. THEME COMMANDS: fancygit --theme-default Change prompt to the default theme. diff --git a/themes/default.sh b/themes/default.sh index db73bb5..a15828c 100644 --- a/themes/default.sh +++ b/themes/default.sh @@ -80,6 +80,7 @@ fancygit_theme_builder() { local time_end="" local prompt_time local prompt_user + local term_title local prompt_env local prompt_path local prompt_double_line @@ -118,13 +119,24 @@ fancygit_theme_builder() { prompt_user="${user_at_host}${user}${user_name}${none}${none} ${user_at_host_end}" fi + local term_title_tag="\\[\\e]0;" + if fancygit_config_is "set_term_title_host" "true" + then + term_title_tag="${term_title_tag}\\h:" + fi + if fancygit_config_is "set_term_title_path" "true" + then + term_title_tag="${term_title_tag}\\w" + fi + term_title="${term_title_tag}\\a\\]" + branch_name=$(fancygit_git_get_branch) if [ "" = "$branch_name" ] then # No branch found, so we're not in a git repo. prompt_env=$(__fancygit_get_venv_icon) prompt_path="${path}${prompt_env} ${prompt_path} ${path_end}${workdir_color_tag}${bg_none}${separator}${none}" - PS1="${clear}${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${clear}${normal_prompt}${prompt_double_line} " + PS1="${term_title}${clear}${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${clear}${normal_prompt}${prompt_double_line} " return fi @@ -156,7 +168,7 @@ fancygit_theme_builder() { notification_area=$(fancygit_get_notification_area "$is_rich_notification") prompt_path="${path_git}${notification_area} ${prompt_path} ${path_end}" prompt_branch="${branch} $(fancygit_git_get_branch_icon "${branch_name}") ${branch_name} ${branch_end}" - PS1="${clear}${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${clear}${normal_prompt}${prompt_double_line} " + PS1="${term_title}${clear}${bold_prompt}${prompt_time}${prompt_user}${prompt_symbol}${prompt_path}${prompt_branch}${clear}${normal_prompt}${prompt_double_line} " } # Here's where the magic happens! diff --git a/themes/human.sh b/themes/human.sh index 9d74dbe..77ac210 100644 --- a/themes/human.sh +++ b/themes/human.sh @@ -60,6 +60,7 @@ fancygit_theme_builder() { local venv_name local prompt_symbol local prompt_path + local term_title local bold_prompt="" local normal_prompt="" @@ -90,6 +91,17 @@ fancygit_theme_builder() { prompt_symbol="" fi + local term_title_tag="\\[\\e]0;" + if fancygit_config_is "set_term_title_host" "true" + then + term_title_tag="${term_title_tag}\\h:" + fi + if fancygit_config_is "set_term_title_path" "true" + then + term_title_tag="${term_title_tag}\\w" + fi + term_title="${term_title_tag}\\a\\]" + if [ "$branch_status" != "" ] then branch="${branch_color_changed_files_font_tag}" @@ -136,11 +148,11 @@ fancygit_theme_builder() { prompt_path="${path_git}${path_sign}${path_end}" prompt_branch="${branch}${branch_name}${branch_end}" PS1="${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name}${preposition_color} on ${prompt_branch}$(fancygit_get_notification_area "$is_rich_notification")" - PS1="${bold_prompt}${PS1}${prompt_symbol}${is_double_line}${normal_prompt} " + PS1="${term_title}${bold_prompt}${PS1}${prompt_symbol}${is_double_line}${normal_prompt} " return fi - PS1="${bold_prompt}${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name}${prompt_symbol}${is_double_line}${normal_prompt} " + PS1="${term_title}${bold_prompt}${prompt_time}${prompt_user_at_host}${prompt_path}${venv_name}${prompt_symbol}${is_double_line}${normal_prompt} " } # Here's where the magic happens! diff --git a/themes/simple.sh b/themes/simple.sh index 08e80bc..d0d0429 100644 --- a/themes/simple.sh +++ b/themes/simple.sh @@ -41,6 +41,7 @@ fancygit_theme_builder() { local at="${at_color_font_tag}@${color_reset}" local path="${workdir_color_font_tag}" local prompt_time + local term_title local path_sign local is_double_line local venv_name @@ -73,12 +74,23 @@ fancygit_theme_builder() { user_at_host="$user:" fi + local term_title_tag="\\[\\e]0;" + if fancygit_config_is "set_term_title_host" "true" + then + term_title_tag="${term_title_tag}\\h:" + fi + if fancygit_config_is "set_term_title_path" "true" + then + term_title_tag="${term_title_tag}\\w" + fi + term_title="${term_title_tag}\\a\\]" + if [ "" != "$venv_name" ] then venv_name="($venv_name) " fi - PS1="${bold_prompt}${venv_name}${prompt_time}${user_at_host}$where\$${branch_area}${is_double_line}${normal_prompt} " + PS1="${term_title}${bold_prompt}${venv_name}${prompt_time}${user_at_host}$where\$${branch_area}${is_double_line}${normal_prompt} " } # ----------------------------------------------------------------------------------------------------------------------