Comments (5)
Hi @starmatt. So you figured out why you had conflicts with you configuration in contrast with the expected behavior. Keep in mind some terminal emulators also interfere with how the title is displayed (e.g. iTerm2, which you can set up to append the currently foreground job to the title, among other stuff).
This seems to work to show the current command after the current working dir:
zstyle ':zim:termtitle' format '%1~ - ${1}' # use single quotes here
zstyle ':zim:termtitle' hooks 'precmd' 'preexec'
You need to set those in your ~/.zshrc and restart your shell for the changes to take effect, as termtitle only gets the configuration once when it's sourced. Maybe I should update the README.md to make that clearer.
from termtitle.
After some digging around, I've found that (duh) a global /etc/zsh/zshrc
was also setting the terminal title, hence why the module was getting overridden when running a command.
I still fail to replicate this behaviour (updating the title with the current running command) with the termtitle
settings. I think I'll disable the module for now and do it manually.
Thanks again.
from termtitle.
Hi, thanks for your answer !
To add to my initial issue, I figured out I actually installed the Grml zsh default configuration on my system, probably a long time ago, and forgot about it 😬. This is relevant for the next part.
Your solution works but it's not exactly what I'm looking for. I'd like the title to show the current directory when a command is not running, then only show the command when it is being ran. This shows an awkward ~ - ${1}
at first, then ~ - vim
when, for example, running vim
, then just ~ -
after the command has ran.
Looking at how the module is presently implemented, I don't think it's possible to get the behaviour I expect as it would need to set 2 different formats for the two hooks, precmd
for the cwd, and preexec
for the program being ran.
I actually implemented this behaviour by myself with help from an example of the arch wiki and parts of the Grml zshrc.
Here's how it looks it my zshrc:
#
# Update the terminal title dynamically
# set_title function defined in /etc/zsh/zshrc
#
# Sets the title as current working directory
function set_title_precmd () {
set_title ${(%):-"%~"}
}
# Sets the title as name of program currently running
function set_title_preexec () {
set_title "${(%):-}" "$2"
}
if [[ "$TERM" == (alacritty*|gnome*|konsole*|putty*|rxvt*|screen*|tmux*|xterm*) ]]; then
autoload -Uz add-zsh-hook
add-zsh-hook -Uz precmd set_title_precmd
add-zsh-hook -Uz preexec set_title_preexec
fi
It would maybe be possible to update termtitle
to do something similar, with settings like
zstyle ':zim:termtitle' format '%1~' hooks 'precmd'
zstyle ':zim:termtitle' format '${1}' hooks 'preexec'
zstyle ':zim:termtitle' format '%~' hooks 'precmd' 'preexec'
and default would be
zstyle ':zim:termtitle' format '%n@%m: %~' hooks 'precmd'
or something...
My zsh knowledege isn't very good and I don't know if this exact syntax is feasible, but I could try to make a PR to the module if you're interested (if I manage to figure out how everything works 😛)
By the way, I didn't congratulate you for your work on the zim framework yet ! I've been using for some time now and I love it, so thank you for your work !
from termtitle.
Hi @starmatt. Great to know you love Zim. Thanks!
In order not to break backwards compatibility, maybe we can introduce the option to have hook-specific formats in this way:
zstyle ':zim:termtitle:precmd' format '%1~'
zstyle ':zim:termtitle:preexec' format '${1}'
If no hook-specific format is defined, the zstyle ':zim:termtitle' format
is used. And the remaining zstyle stay and work as they are now.
from termtitle.
@starmatt, I finally tacked this. I've come up with a simple code that is generic enough to accept custom formats for any hook (not just for preexec).
from termtitle.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from termtitle.