initial commit

This commit is contained in:
2025-06-03 14:16:01 +03:00
commit 6fed9ef617
683 changed files with 109296 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
# Force text files to have unix eols, so Windows/Cygwin does not break them
*.* eol=lf
*.gif binary
*.png binary

View File

@@ -0,0 +1,18 @@
# Changelog
### master
- to speed up the "online test" ping uses only 1 packet
- fix issue with status-right and status-left whitespace being cut out
- add ping default timeout (@mjwhitta)
### v1.0.0, 2014-10-26
- README updates
- update readme to reflect github organization changes
- linux can't display default offline icon - update it
- add "@route_to_ping" option
### v0.0.2, 2014-06-02
- bugfix: offline status icon wasn't displaying properly
### v0.0.1, 2014-06-02
- first working version

View File

@@ -0,0 +1,19 @@
Copyright (C) 2014 Bruno Sutic
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,92 @@
# Tmux online status
Tmux plugin that enables displaying online status for your workstation.
Introduces a new `#{online_status}` format.
This plugin is useful if:
- you spend most of your time in Tmux and don't want to "switch" away from
the terminal to check whether you're connected.
- you have a flaky internet connection and you don't want to be surprised
when a simple `curl` or `wget` fails because the connection just broke.
Tested and working on Linux, OSX, FreeBSD, and Cygwin.
### Usage
Add `#{online_status}` format string to your existing `status-right` tmux
option.
Here's the example in `.tmux.conf`:
set -g status-right "Online: #{online_status} | %a %h-%d %H:%M "
**OS X**<br/>
On OS X the above will look like this when online<br/>
![online indicator](/screenshots/online_indicator.png)<br/>
or this when offline<br/>
![offline indicator](/screenshots/offline_indicator.png)<br/>
**Linux**<br/>
Online status on Linux<br/>
![online indicator](/screenshots/online_indicator_linux.png)<br/>
offline status<br/>
![offline indicator](/screenshots/offline_indicator_linux.png)<br/>
#### Configure icons
If the icons don't display well on your machine you can change them in
`.tmux.conf`:
set -g @online_icon "ok"
set -g @offline_icon "offline!"
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
Add plugin to the list of TPM plugins in `.tmux.conf`:
set -g @plugin 'tmux-plugins/tmux-online-status'
Hit `prefix + I` to fetch the plugin and source it.
`#{online_status}` interpolation should now work.
### Manual Installation
Clone the repo:
$ git clone https://github.com/tmux-plugins/tmux-online-status ~/clone/path
Add this line to the bottom of `.tmux.conf`:
run-shell ~/clone/path/online_status.tmux
Reload TMUX environment:
# type this in terminal
$ tmux source-file ~/.tmux.conf
`#{online_status}` interpolation should now work.
### Limitations
Online status icon most likely won't be instant. The duration depends on the
`status-interval` Tmux option. So, it might take anywhere between 5 and 60
seconds for online status icon to change.
Set `status-interval` to a low number to make this faster, example:
# in .tmux.conf
set -g status-interval 5
### Other plugins
You might also find these useful:
- [battery](https://github.com/tmux-plugins/tmux-battery) - battery status in
Tmux `status-right`
- [logging](https://github.com/tmux-plugins/tmux-logging) - easy logging and
screen capturing
### License
[MIT](LICENSE.md)

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
online_status_icon="#($CURRENT_DIR/scripts/online_status_icon.sh)"
online_status_interpolation_string="\#{online_status}"
source $CURRENT_DIR/scripts/shared.sh
do_interpolation() {
local string="$1"
local interpolated="${string/$online_status_interpolation_string/$online_status_icon}"
echo "$interpolated"
}
update_tmux_option() {
local option="$1"
local option_value="$(get_tmux_option "$option")"
local new_option_value="$(do_interpolation "$option_value")"
set_tmux_option "$option" "$new_option_value"
}
main() {
update_tmux_option "status-right"
update_tmux_option "status-left"
}
main

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,77 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
online_option_string="@online_icon"
offline_option_string="@offline_icon"
ping_timeout_string="@ping_timeout"
route_to_ping_string="@route_to_ping"
online_icon_osx="✅ "
online_icon="✔"
offline_icon_osx="⛔️ "
offline_icon_cygwin="X"
offline_icon="❌ "
ping_timeout_default="3"
route_to_ping_default="www.google.com"
source $CURRENT_DIR/shared.sh
is_osx() {
[ $(uname) == "Darwin" ]
}
is_cygwin() {
[[ $(uname) =~ CYGWIN ]]
}
is_freebsd() {
[ $(uname) == FreeBSD ]
}
online_icon_default() {
if is_osx; then
echo "$online_icon_osx"
else
echo "$online_icon"
fi
}
offline_icon_default() {
if is_osx; then
echo "$offline_icon_osx"
elif is_cygwin; then
echo "$offline_icon_cygwin"
else
echo "$offline_icon"
fi
}
online_status() {
if is_osx || is_freebsd; then
local timeout_flag="-t"
else
local timeout_flag="-w"
fi
if is_cygwin; then
local number_pings_flag="-n"
else
local number_pings_flag="-c"
fi
local ping_timeout="$(get_tmux_option "$ping_timeout_string" "$ping_timeout_default")"
local ping_route="$(get_tmux_option "$route_to_ping_string" "$route_to_ping_default")"
ping "$number_pings_flag" 1 "$timeout_flag" "$ping_timeout" "$ping_route" >/dev/null 2>&1
}
print_icon() {
if $(online_status); then
printf "$(get_tmux_option "$online_option_string" "$(online_icon_default)")"
else
printf "$(get_tmux_option "$offline_option_string" "$(offline_icon_default)")"
fi
}
main() {
print_icon
}
main

View File

@@ -0,0 +1,16 @@
get_tmux_option() {
local option=$1
local default_value=$2
local option_value=$(tmux show-option -gqv "$option")
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
}
set_tmux_option() {
local option="$1"
local value="$2"
tmux set-option -gq "$option" "$value"
}