dotfiles/config/powerline-shell/segments/set_term_title.py

23 lines
704 B
Python
Raw Normal View History

2021-04-20 11:12:35 +00:00
import os
import socket
from ..utils import BasicSegment
class Segment(BasicSegment):
def add_to_powerline(self):
powerline = self.powerline
term = os.getenv('TERM')
if not (('xterm' in term) or ('rxvt' in term)):
return
if powerline.args.shell == 'bash':
set_title = '\\[\\e]0;\\u@\\h: \\w\\a\\]'
elif powerline.args.shell == 'zsh':
set_title = '%{\033]0;%n@%m: %~\007%}'
else:
set_title = '\033]0;%s@%s: %s\007' % (
os.getenv('USER'),
socket.gethostname().split('.')[0],
powerline.cwd,
)
powerline.append(set_title, None, None, '')