Skip to content
Grimmer edited this page Feb 16, 2020 · 5 revisions

Welcome to the terminal-title-change wiki!

Homebrew notes

There are 3 ways to distribute python console program to Homebrew.

  1. pure python:

https://github.com/grimmer0125/homebrew-core/blob/termtitle/Formula/termtitle.rb, the setting is referenced from httpie

  1. 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"
  1. compile python

https://github.com/Homebrew/homebrew-core/blob/master/Formula/youtube-dl.rb https://github.com/rg3/youtube-dl/blob/master/setup.py

how to distribute command line script on PyPI (pip)

two ways in setup.py, e.g.

scripts=['sayhello.py']
entry_points
	console_scripts: [
		"termtitle = termtitle.termtitle:change_title"

windows issue

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.

ubuntu 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.

Some unix terminal programs

Interesting Homebrew formula

Homebrew:

  1. Open terminal in specified directory (and optionally run command) https://github.com/liyanage/macosx-shell-scripts/blob/master/term

  2. brew install xtitle

PyPI:

  1. Opens a new OS X Terminal window in the current directory and runs an optional command in it. https://github.com/bartTC/tab