You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’d like to propose an improvement to the run_segment function within the hostname.sh file. Currently, the function supports fetching the hostname in “short” or “long” format. However, it would be beneficial to add support for a custom option that allows users to pass a predefined string to be displayed instead of the actual hostname.
Proposed Changes
1. Enhance run_segment
The function is updated to handle three cases: “short”, “long”, and a “custom” option. Here’s the modified code for the run_segment function:
run_segment() {
local opts=""if [ "$TMUX_POWERLINE_SEG_HOSTNAME_FORMAT"=="short" ];thenif shell_is_osx || shell_is_bsd;then
opts="-s"else
opts="--short"fi# Display the hostname in short format
hostname ${opts}return 0
elif [ "$TMUX_POWERLINE_SEG_HOSTNAME_FORMAT"=="long" ];then# Display the hostname in long format (default)
hostname
return 0
else# If neither "short" nor "long", display the custom stringecho"$TMUX_POWERLINE_SEG_HOSTNAME_FORMAT"return 0
fi
}
2. Update config.sh
To support the new “custom” option, update the hostname.sh configuration example as follows:
# hostname.sh {# Use short, long, or custom format for the hostname. Can be {"short", "long", "custom"}.export TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="MYLAPTOP"# }
Example Behavior
When TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="short":
Output: hostname -s
When TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="long":
Output: hostname
When TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="MYLAPTOP":
Output: MYLAPTOP
Benefits
Adds flexibility for users who want to display a custom string instead of their system hostname.
Updates the configuration file to make the custom option visible and easy to use.
Maintains backward compatibility for “short” and “long” options.
Request
If this sounds like a valuable enhancement, I’d be happy to collaborate further or submit a Pull Request with the implementation. Let me know your thoughts!
Thanks for considering this suggestion!
The text was updated successfully, but these errors were encountered:
Hi,
I’d like to propose an improvement to the
run_segment
function within thehostname.sh
file. Currently, the function supports fetching the hostname in “short” or “long” format. However, it would be beneficial to add support for a custom option that allows users to pass a predefined string to be displayed instead of the actual hostname.Proposed Changes
1. Enhance
run_segment
The function is updated to handle three cases: “short”, “long”, and a “custom” option. Here’s the modified code for the
run_segment
function:2. Update
config.sh
To support the new “custom” option, update the
hostname.sh
configuration example as follows:Example Behavior
When
TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="short"
:Output:
hostname -s
When
TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="long"
:Output:
hostname
When
TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="MYLAPTOP"
:Output:
MYLAPTOP
Benefits
Request
If this sounds like a valuable enhancement, I’d be happy to collaborate further or submit a Pull Request with the implementation. Let me know your thoughts!
Thanks for considering this suggestion!
The text was updated successfully, but these errors were encountered: