-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the terminal-title-change wiki!
There are 3 ways to distribute python console program to Homebrew.
- pure python:
https://github.com/grimmer0125/homebrew-core/blob/termtitle/Formula/termtitle.rb, the setting is referenced from httpie
- make a script to invoke python:
https://stackoverflow.com/questions/31660485/simple-homebrew-formula-for-python
libexec.install "test.sh", "main.py"
bin.install_symlink libexec/"test.sh" => "test"
- compile python
https://github.com/Homebrew/homebrew-core/blob/master/Formula/youtube-dl.rb https://github.com/rg3/youtube-dl/blob/master/setup.py
two ways in setup.py, e.g.
scripts=['sayhello.py']
entry_points
console_scripts: [
"termtitle = termtitle.termtitle:change_title"
In terminal, execute python
to enter python interpreter,
Ether
>>> import os
>>> os.system("title test")
or
import ctypes
ctypes.windll.kernel32.SetConsoleTitleW("My New Title")
will work.
But saving the script to a file (e.g. title.py
), python title.py
does not change the current title. it is similar to Ubuntu $PS1
issue.
Since Ubuntu 16.04, escape sequence used is invalid due to $PS1 environment variable. Python interpreter process can not modify it (a kind of system process setting). So the only way is to change $PS1 in ~/.bashrc.
Homebrew:
-
Open terminal in specified directory (and optionally run command) https://github.com/liyanage/macosx-shell-scripts/blob/master/term
-
brew install xtitle
PyPI:
- Opens a new OS X Terminal window in the current directory and runs an optional command in it. https://github.com/bartTC/tab