Skip to content

How can I add the current directory path to the title bar when a process is running #7568

Closed Answered by amirkarimi
amirkarimi asked this question in Q&A
Discussion options

You must be logged in to vote

Could achieve that by disabling the title integration in kitty (shell_integration enabled no-title in the config) adding the following to my .zshrc:

# Function to set terminal title
function set_terminal_title() {
  if [[ -n "$1" ]]; then
    # When a process is running, show the command and the current directory
    print -Pn "\e]0;$PWD | $1\a"
  else
    # Default title showing only the current directory
    print -Pn "\e]0;$PWD\a"
  fi
}

# Pre-command hook to update the terminal title before each command
function preexec() {
  # Update the terminal title with the running command and the current directory
  set_terminal_title "$1"
}

# Post-command hook to reset the terminal title afte…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amirkarimi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant