Skip to content

Commit

Permalink
Merge pull request #1 from trystan2k/release/1.1.0
Browse files Browse the repository at this point in the history
Release/1.1.0
  • Loading branch information
trystan2k authored Jan 4, 2020
2 parents f5f942e + d33ee5b commit a99371d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ZSH Tab Title

[![v1.0.0](https://img.shields.io/badge/version-1.0.0-brightgreen.svg)](https://github.com/trystan2k/zsh-tab-title/tree/v1.0.0)
[![v1.1.0](https://img.shields.io/badge/version-1.1.0-brightgreen.svg)](https://github.com/trystan2k/zsh-tab-title/tree/v1.1.0)

A zsh plugin that allows you to set a terminal header like any of PROMPT

Expand Down Expand Up @@ -30,3 +30,30 @@ Add `antigen bundle trystan2k/zsh-tab-title` into `.zshrc`

Add `zgen load trystan2k/zsh-tab-title` into `.zshrc`

## Configuration

You can configure the prefix and/or suffix to be showed in tab title, besides the current folder.

### PREFIX

The prefix can be configured using the variable `ZSH_TAB_TITLE_PREFIX` and it will be added **before** the current folder, in tab title. For example:

```sh
ZSH_TAB_TITLE_PREFIX='$USER@$HOST - '
```

By default, if no value is informed, it is used the value `%m@%n:` which will show the user name and computer name, separated by @. For example: `trystan2k@MyPC: /home/trystan2k`. This default value can be disabled if variable `ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX` is set to try. For example:

```sh
ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true
```

### SUFFIX

The suffix can be configured using the variable `ZSH_TAB_TITLE_SUFFIX` and it will be added **after** the current folder, in tab title. For example:

```sh
ZSH_TAB_TITLE_SUFFIX='- $USER'
```

This variable has no default value, so if nothing is informed, no suffix is added
11 changes: 9 additions & 2 deletions title.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ function title {
}

ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"

if [[ "$ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX" == true ]]; then
ZSH_TAB_TITLE_PREFIX=""
elif [[ -z "$ZSH_TAB_TITLE_PREFIX" ]]; then
ZSH_TAB_TITLE_PREFIX="%n@%m:"
fi

ZSH_THEME_TERM_TITLE_IDLE="$ZSH_TAB_TITLE_PREFIX %~ $ZSH_TAB_TITLE_SUFFIX"
# Avoid duplication of directory in terminals with independent dir display
if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
ZSH_THEME_TERM_TITLE_IDLE="$ZSH_TAB_TITLE_PREFIX $ZSH_TAB_TITLE_SUFFIX"
fi

# Runs before showing the prompt
Expand Down

0 comments on commit a99371d

Please sign in to comment.