-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: macOS support improvements (#63)
- Loading branch information
Showing
12 changed files
with
128 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Compatibility functions for macOS | ||
if [[ "$(uname)" == "Darwin" ]]; then | ||
HOMEBREW_PREFIX="$(brew --prefix)" | ||
# Use GNU coreutils if available | ||
if [ -d "$HOMEBREW_PREFIX/opt/coreutils" ]; then | ||
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" | ||
fi | ||
# Use GNU awk if available | ||
if [ -d "$HOMEBREW_PREFIX/opt/gawk" ]; then | ||
export PATH="$HOMEBREW_PREFIX/opt/gawk/libexec/gnubin:$PATH" | ||
fi | ||
# Use GNU sed if available | ||
if [ -d "$HOMEBREW_PREFIX/opt/gsed" ]; then | ||
export PATH="$HOMEBREW_PREFIX/opt/gsed/libexec/gnubin:$PATH" | ||
fi | ||
# Use Homebrew bc if available | ||
if [ -d "$HOMEBREW_PREFIX/opt/bc" ]; then | ||
export PATH="$HOMEBREW_PREFIX/opt/bc/bin:$PATH" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ | |
# email : [email protected] | ||
#<------------------------------------------------------------------------------------------> | ||
|
||
# Imports | ||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." | ||
. "${ROOT_DIR}/lib/coreutils-compat.sh" | ||
|
||
# Check the global value | ||
SHOW_NETSPEED=$(tmux show-option -gv @tokyo-night-tmux_show_netspeed) | ||
if [ "$SHOW_NETSPEED" != "1" ]; then | ||
|
@@ -18,7 +22,15 @@ INTERFACE=$(tmux show-option -gv @tokyo-night-tmux_netspeed_iface 2>/dev/null) | |
|
||
# Get network transmit data from /proc/net/dev | ||
get_bytes() { | ||
awk -v interface="$1" '$1 == interface ":" {print $2, $10}' /proc/net/dev | ||
local interface="$1" | ||
if [[ "$(uname)" == "Linux" ]]; then | ||
awk -v interface="$interface" '$1 == interface ":" {print $2, $10}' /proc/net/dev | ||
elif [[ "$(uname)" == "Darwin" ]]; then | ||
netstat -ib | awk -v interface="$interface" '/^'${interface}'/ {print $7, $10}' | ||
else | ||
# Unsupported operating system | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Convert into readable format | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters