> For the complete documentation index, see [llms.txt](https://www.techwithtyler.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.techwithtyler.dev/operating-systems/macos/terminal-customization.md).

# Terminal Customization

## Hostname in Terminal

By default, the Terminal app will display your <username@hostname.local>.&#x20;

* We can change the hostname by going to **System Settings > General > About** but this still leaves `.local` appended within the Terminal
* So instead we can run this command `sudo scutil --set HostName <new_hostname>`

<figure><img src="/files/Pig4wXstzPZKqeMakWup" alt=""><figcaption></figcaption></figure>

***

## ZSH Shell

### Completion Features

{% code overflow="wrap" %}

```bash
# enable auto-completion for applicable apps installed with brew e.g., gh.
# https://docs.brew.sh/Shell-Completion
if type brew &>/dev/null
then
  FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"

  autoload -Uz compinit
  compinit
fi
```

{% endcode %}

```bash
# automatically capitalizes where needed e.g., `cd documents/` >> `cd Documents/`
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
```

***

### Auto-Suggestions

```sh
printf '\n#enables suggestions based on previously used commands\nsource /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh\n' >> ~/.zshrc
```

<figure><img src="/files/SG8cF3PQ4LXUa6lWR4m9" alt=""><figcaption><p>hit left arrow key to use suggestion</p></figcaption></figure>

***

### Enable Shell Completion

```zsh
echo "autoload -U compinit; compinit" >> ~/.zshrc
```

***

### Display Current Git Branch

```sh
# add to ~/.zsh
# updates shell colors, format, and displays git branch
parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
# color #s found here: https://misc.flogisoft.com/bash/tip_colors_and_formatting
COLOR_DEF='%f'
COLOR_USR='%F{243}'
COLOR_DIR='%F{197}'
COLOR_GIT='%F{39}'
NEWLINE=$'\n'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
```

<figure><img src="/files/TnFw7lTuImwobKyflDhA" alt=""><figcaption><p>new colors and git branch in name</p></figcaption></figure>
