Skip to content

Commit

Permalink
feat: adds hostname widget (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
janoamaral authored Oct 17, 2024
2 parents e974aa1 + 9fb1dcf commit dffa0a7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ set -g @tokyo-night-tmux_battery_low_threshold 21 # default
Set variable value `0` to disable the widget. Remember to restart `tmux` after
changing values.

#### Hostname Widget

```bash
set -g @tokyo-night-tmux_show_hostname 1
```

![Snap hostname](snaps/hostname.png)

## Styles

- `none`: no style, default font
Expand Down
Binary file added snaps/hostname.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/hostname-widget.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Imports
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
. "${ROOT_DIR}/lib/coreutils-compat.sh"

# Check if enabled
ENABLED=$(tmux show-option -gv @tokyo-night-tmux_show_hostname 2>/dev/null)
[[ ${ENABLED} -ne 1 ]] && exit 0

CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source $CURRENT_DIR/themes.sh

hostname=$(hostnamectl hostname)

echo "#[fg=red,bold,bg=default]░ @ #[fg=brightwhite,bg=${THEME[background]}]${hostname}"
3 changes: 2 additions & 1 deletion tokyo-night.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ zoom_number="#($SCRIPTS_PATH/custom-number.sh #P $zoom_id_style)"
date_and_time="$($SCRIPTS_PATH/datetime-widget.sh)"
current_path="#($SCRIPTS_PATH/path-widget.sh #{pane_current_path})"
battery_status="#($SCRIPTS_PATH/battery-widget.sh)"
hostname="#($SCRIPTS_PATH/hostname-widget.sh)"

#+--- Bars LEFT ---+
# Session name
Expand All @@ -63,5 +64,5 @@ tmux set -g window-status-current-format "$RESET#[fg=${THEME[green]},bg=${THEME[
tmux set -g window-status-format "$RESET#[fg=${THEME[foreground]}] #{?#{==:#{pane_current_command},ssh},󰣀 , }${RESET}$window_number#W#[nobold,dim]#{?window_zoomed_flag, $zoom_number, $custom_pane}#[fg=${THEME[yellow]}]#{?window_last_flag,󰁯 , }"

#+--- Bars RIGHT ---+
tmux set -g status-right "$battery_status$current_path$cmus_status$netspeed$git_status$wb_git_status$date_and_time"
tmux set -g status-right "$battery_status$current_path$cmus_status$netspeed$git_status$wb_git_status$date_and_time$hostname"
tmux set -g window-status-separator ""

0 comments on commit dffa0a7

Please sign in to comment.