Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add only_on_ssh option for hostname segment #552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,11 @@ The options for the `cwd` segment are:
- `full_cwd`: If true, the last directory will not be shortened when
`max_dir_size` is used.

The `hostname` segment provides one option:
The `hostname` segment provides two options:

- `colorize`: If true, the hostname will be colorized based on a hash of
itself.
- `only_on_ssh`: If true, the hostname will only be shown if connected via SSH.

The `vcs` segment provides one option:

Expand Down
4 changes: 4 additions & 0 deletions powerline_shell/segments/hostname.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from ..utils import BasicSegment
from ..color_compliment import stringToHashToColorAndOpposite
from ..colortrans import rgb2short
Expand All @@ -7,6 +8,9 @@
class Segment(BasicSegment):
def add_to_powerline(self):
powerline = self.powerline
if powerline.segment_conf("hostname", "only_on_ssh"):
if not os.getenv('SSH_CLIENT'):
return
if powerline.segment_conf("hostname", "colorize"):
hostname = gethostname()
FG, BG = stringToHashToColorAndOpposite(hostname)
Expand Down