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 format option for time segment #383

Merged
merged 1 commit into from
May 7, 2018
Merged
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ The options for the `battery` segment are:
- `always_show_percentage`: If true, show percentage when fully charged on AC.
- `low_threshold`: Threshold percentage for low-battery indicator color.

The options for the `time` segment are:

- `format`: Format string as used by strftime function, e.g. `%H:%M`.

### Contributing new types of segments

The `powerline_shell/segments` directory contains python scripts which are
Expand Down
5 changes: 4 additions & 1 deletion powerline_shell/segments/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
class Segment(BasicSegment):
def add_to_powerline(self):
powerline = self.powerline
if powerline.args.shell == 'bash':
format = powerline.segment_conf('time', 'format')
if format:
time_ = ' %s ' % time.strftime(format)
elif powerline.args.shell == 'bash':
time_ = ' \\t '
elif powerline.args.shell == 'zsh':
time_ = ' %* '
Expand Down