feat: datcode
This commit is contained in:
commit
25bb67e958
66 changed files with 5821 additions and 0 deletions
3
data/config/opencode.json
Normal file
3
data/config/opencode.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"$schema": "https://opencode.ai/config.json"
|
||||
}
|
||||
13
data/config/tui.json
Normal file
13
data/config/tui.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://opencode.ai/tui.json",
|
||||
"keybinds": {
|
||||
"input_buffer_home": "ctrl+home",
|
||||
"input_buffer_end": "ctrl+end",
|
||||
"input_line_home": "home",
|
||||
"input_line_end": "end",
|
||||
"messages_first": "ctrl+home",
|
||||
"messages_last": "ctrl+end",
|
||||
"app_exit": "ctrl+q",
|
||||
"input_delete_word_backward": "ctrl+backspace"
|
||||
}
|
||||
}
|
||||
0
data/share/.gitkeep
Normal file
0
data/share/.gitkeep
Normal file
0
data/state/.gitkeep
Normal file
0
data/state/.gitkeep
Normal file
5
data/tmux/plugins/tmux/.editorconfig
Normal file
5
data/tmux/plugins/tmux/.editorconfig
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[*]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
28
data/tmux/plugins/tmux/.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
28
data/tmux/plugins/tmux/.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
name: Bug Report
|
||||
about: Report a bug to help us improve
|
||||
title: 'Bug: [this doesn''t work]'
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Describe the bug
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### To Reproduce
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
### Expected behavior
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### Screenshots
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
### System
|
||||
- OS:
|
||||
- Tmux Version:
|
||||
17
data/tmux/plugins/tmux/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
17
data/tmux/plugins/tmux/.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: 'Enhancement: [add this functionality]'
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Describe the feature you'd like
|
||||
A clear and concise description of what you want added to this project.
|
||||
|
||||
### Describe risks you've considered
|
||||
A clear and concise description of some potential risks of adding such a feature.
|
||||
|
||||
### Describe alternatives you've considered
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
12
data/tmux/plugins/tmux/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
vendored
Normal file
12
data/tmux/plugins/tmux/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
## Issue
|
||||
|
||||
Please reference the issue that this PR is solving
|
||||
Closes #[issue id goes here]
|
||||
|
||||
## Description of Changes
|
||||
|
||||
Please briefly describe the changes being made
|
||||
|
||||
## Testing
|
||||
|
||||
Please explain how you tested these changes and how a maintainer should reproduce the test
|
||||
14
data/tmux/plugins/tmux/.github/workflows/check-syntax.yml
vendored
Normal file
14
data/tmux/plugins/tmux/.github/workflows/check-syntax.yml
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
name: Check Syntax
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@master
|
||||
- name: syntax-check
|
||||
run: for i in $(ls); do echo $i; if [ ! -z $(bash -n $i) ]; then $(exit 1); fi; done
|
||||
working-directory: scripts
|
||||
shell: bash
|
||||
2
data/tmux/plugins/tmux/.gitignore
vendored
Normal file
2
data/tmux/plugins/tmux/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
data/weather.txt
|
||||
tmux.conf
|
||||
37
data/tmux/plugins/tmux/CONTRIBUTING.md
Normal file
37
data/tmux/plugins/tmux/CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Dracula Tmux
|
||||
|
||||
Thank you for your interesting in Dracula Tmux and for your contribution.
|
||||
|
||||
We welcome all feature requests, bug reports, and contributions, given that they
|
||||
follow the guidelines below.
|
||||
|
||||
Dracula Tmux is developed and maintained by volunteers and students, please be
|
||||
patient when waiting for PR reviews or filing issues.
|
||||
|
||||
## Contributing To Dracula Tmux
|
||||
|
||||
### LLM "AI" usage
|
||||
|
||||
At this time, the Dracula Tmux project permits the usage of LLMs (commonly referred
|
||||
to as AI) during the contribution process under the following guidelines:
|
||||
|
||||
1. Code contributions are permitted
|
||||
2. LLM-generated commit messages, PR descriptions, issues, and code comments (including bug reports) are explicitly forbidden
|
||||
3. All submitted code must be fully explained, justified, and understood by the human contributing the changes
|
||||
4. Humans must be in the loop for the entire lifecycle of all contributions
|
||||
5. Contributions from autonomous agentic closed loops like OpenClaw or Hermes are explicitly forbidden
|
||||
|
||||
#### LLM "AI" Transparency
|
||||
|
||||
All LLM usage must be fully and transparently disclosed in issue or PR creation.
|
||||
|
||||
This disclosure must be in the form of the `Assisted-by` Git commit trailer,
|
||||
including the tool or harness name as well as the primary model and version used.
|
||||
A `Co-authored-by:` (commonly used by Claude Code) trailer does not satisfy this policy.
|
||||
|
||||
## Enforcement
|
||||
|
||||
If a contribution (be it a PR or issue) is in violation of the above
|
||||
guidelines, it may be closed without review or explanation.
|
||||
|
||||
Repeat offenders may be banned from future submissions.
|
||||
47
data/tmux/plugins/tmux/INSTALL.md
Normal file
47
data/tmux/plugins/tmux/INSTALL.md
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
### [tmux](https://github.com/tmux/tmux/wiki)
|
||||
|
||||
#### Install using [tpm](https://github.com/tmux-plugins/tpm)
|
||||
|
||||
If you are a tpm user, you can install the theme and keep up to date by adding the following to your .tmux.conf file:
|
||||
|
||||
set -g @plugin 'dracula/tmux'
|
||||
|
||||
Add any configuration options below this line in your tmux config.
|
||||
|
||||
#### Install with [Nix](https://nixos.org)
|
||||
|
||||
If you're using [home-manager](https://github.com/nix-community/home-manager), an example config would look similar to this:
|
||||
Then run `home-manager switch`, the `Activating theme` section doesn't apply here.
|
||||
|
||||
```nix
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
clock24 = true;
|
||||
plugins = with pkgs.tmuxPlugins; [
|
||||
sensible
|
||||
yank
|
||||
{
|
||||
plugin = dracula;
|
||||
extraConfig = ''
|
||||
set -g @dracula-show-battery false
|
||||
set -g @dracula-show-powerline true
|
||||
set -g @dracula-refresh-rate 10
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
extraConfig = ''
|
||||
set -g mouse on
|
||||
'';
|
||||
};
|
||||
```
|
||||
|
||||
#### Activating theme
|
||||
|
||||
1. Make sure `run -b '~/.tmux/plugins/tpm/tpm'` is at the bottom of your .tmux.conf
|
||||
2. Run tmux
|
||||
3. Use the tpm install command: `prefix + I` (default prefix is ctrl+b)
|
||||
|
||||
#### Configuration
|
||||
|
||||
The configuration options are documented on [our GitHub](https://github.com/dracula/tmux/blob/master/docs/CONFIG.md)
|
||||
21
data/tmux/plugins/tmux/LICENSE
Normal file
21
data/tmux/plugins/tmux/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Dane Williams
|
||||
|
||||
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.
|
||||
75
data/tmux/plugins/tmux/README.md
Normal file
75
data/tmux/plugins/tmux/README.md
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# Dracula for [tmux](https://github.com/tmux/tmux/wiki)
|
||||
|
||||
> A dark theme for [tmux](https://github.com/tmux/tmux/wiki)
|
||||
|
||||

|
||||
|
||||
## Install
|
||||
|
||||
All instructions can be found [in the docs](./INSTALL.md).
|
||||
|
||||
## Configuration
|
||||
|
||||
Configuration and options can be found [in the docs](/docs/CONFIG.md).
|
||||
|
||||
## Color Theming
|
||||
|
||||
In depth configuration of Colors and alternative themes can be found [in the docs](/docs/color_theming/README.md)
|
||||
|
||||
## Features
|
||||
|
||||
- Support for powerline
|
||||
- Support for NerdFonts
|
||||
- Day, date, time, timezone
|
||||
- [Fully custom color theming](/docs/color_theming/README.md)
|
||||
- Current location based on network with temperature and forecast icon (if available)
|
||||
- SSH session user, hostname and port of active tmux pane
|
||||
- Network connection status, bandwidth, SSID and public IP (requires `curl`)
|
||||
- Git branch and status
|
||||
- Battery percentage and AC power connection status with icons
|
||||
- Refresh rate control
|
||||
- CPU usage (percentage or load average)
|
||||
- CPU architecture
|
||||
- RAM usage (system and/or tmux server)
|
||||
- Custom status texts from external scripts
|
||||
- GPU stats
|
||||
- usage, power draw, and VRAM usage for NVIDIA on Linux, with partial support for amd/ intel
|
||||
- usage, and power draw for MacOS. **requires sudo privileges**
|
||||
- Color code based on whether a prefix is active or not
|
||||
- List of windows with the current window highlighted
|
||||
- When prefix is enabled, the left status bar widget turns from green to yellow
|
||||
- If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature
|
||||
- Read system temperature
|
||||
- Read system uptime
|
||||
- Info if the Panes are synchronized
|
||||
- Spotify playback (needs the tool spotify-tui installed). max-len can be configured.
|
||||
- Music Player Daemon status (needs the tool mpc installed)
|
||||
- Playerctl, get current track metadata
|
||||
- Current kubernetes context
|
||||
- Countdown to tmux-continuum save
|
||||
- Current working directory of tmux pane
|
||||
- Kerberos TGT expiration date
|
||||
- Show your Libre Freestyle 3 readings [Setup instructions](./scripts/libre.sh)
|
||||
|
||||
## Compatibility
|
||||
|
||||
Compatible with macOS and Linux. Tested on tmux 3.1b
|
||||
FreeBSD compatibility is in development
|
||||
|
||||
## Team
|
||||
|
||||
This theme is maintained by the following person(s) and a bunch of [awesome contributors](https://github.com/dracula/tmux/graphs/contributors).
|
||||
|
||||
| [](https://github.com/ethancedwards8) | [](https://github.com/theoreticallyhugo) | [](https://github.com/danerwilliams) |
|
||||
|-------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
|
||||
| [Ethan Edwards](https://github.com/ethancedwards8) | [Hugo Meinhof](https://github.com/theoreticallyhugo) | [Dane Williams](https://github.com/danerwilliams) |
|
||||
|
||||
## Community
|
||||
|
||||
- [Twitter](https://twitter.com/draculatheme) - Best for getting updates about themes and new stuff.
|
||||
- [GitHub](https://github.com/dracula/dracula-theme/discussions) - Best for asking questions and discussing issues.
|
||||
- [Discord](https://draculatheme.com/discord-invite) - Best for hanging out with the community.
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](./LICENSE)
|
||||
0
data/tmux/plugins/tmux/data/.gitkeep
Normal file
0
data/tmux/plugins/tmux/data/.gitkeep
Normal file
973
data/tmux/plugins/tmux/docs/CONFIG.md
Normal file
973
data/tmux/plugins/tmux/docs/CONFIG.md
Normal file
|
|
@ -0,0 +1,973 @@
|
|||
# [tmux](https://github.com/tmux/tmux/wiki)
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Configuration](#Configuration---up)
|
||||
- [Status bar options](#status-bar-options---up)
|
||||
- [Powerline](#powerline---up)
|
||||
- [Left Icon](#left-icon---up)
|
||||
- [Color theming](/docs/color_theming/README.md)
|
||||
- [Plugins](#Plugins)
|
||||
- [attached-clients](#attached-clients---up)
|
||||
- [battery](#battery---up)
|
||||
- [compact-alt](#compact-alt---up)
|
||||
- [continuum](#continuum---up)
|
||||
- [cpu-arch](#cpu-arch---up)
|
||||
- [cpu-usage](#cpu-usage---up)
|
||||
- [cwd](#cwd---up)
|
||||
- [fossil](#fossil---up)
|
||||
- [git](#git---up)
|
||||
- [GPU Info (gpu-usage, gpu-ram-usage, gpu-power-draw)](#gpu-info---up)
|
||||
- [hg](#hg---up)
|
||||
- [Kerberos TGT (krbtgt)](#Kerberos-TGT---up)
|
||||
- [kubernetes-context](#kubernetes-context---up)
|
||||
- [libreview](#libreview---up)
|
||||
- [mac-player](#mac-player---up)
|
||||
- [mpc](#mpc---up)
|
||||
- [network](#network---up)
|
||||
- [network-public-ip](#network-public-ip---up)
|
||||
- [network-bandwidth](#network-bandwidth---up)
|
||||
- [network-ping](#network-ping---up)
|
||||
- [network-vpn](#network-vpn---up)
|
||||
- [playerctl](#playerctl---up)
|
||||
- [ram-usage](#ram-usage---up)
|
||||
- [spotify-tui](#spotify-tui---up)
|
||||
- [spr](#spr---up)
|
||||
- [ssh-session](#ssh-session---up)
|
||||
- [synchronize-panes](#synchronize-panes---up)
|
||||
- [sys-temp](#sys-temp---up)
|
||||
- [terraform](#terraform---up)
|
||||
- [time](#time---up)
|
||||
- [tmux-ram-usage](#tmux-ram-usage---up)
|
||||
- [uptime](#uptime---up)
|
||||
- [weather](#weather---up)
|
||||
- [custom:script-name](#customscript-name---up)
|
||||
|
||||
## Configuration - [up](#table-of-contents)
|
||||
|
||||
The following configuration works regardless of whether you are using `$HOME/.tmux.conf`, or `$XDG_CONFIG_HOME/tmux/tmux.conf`.
|
||||
To enable plugins set up the `@dracula-plugins` option in your `.tmux.conf` file, separate plugin by space.
|
||||
The order that you define the plugins will be the order on the status bar left to right.
|
||||
The name of the plugin used in the [table of contents](#table-of-contents), as well as each plugins headline, is the name to be used in the `@dracula-plugins` option.
|
||||
|
||||
```bash
|
||||
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage"
|
||||
```
|
||||
|
||||
For each plugin is possible to customize background and foreground colors.
|
||||
For more fine-grained color customization please reference [Color theming](/docs/color_theming/README.md).
|
||||
|
||||
```bash
|
||||
# per default available colors: white, gray, dark_gray, light_purple, dark_purple, cyan, green, orange, red, pink, yellow
|
||||
# set -g @dracula-[plugin-name]-colors "[background] [foreground]"
|
||||
set -g @dracula-cpu-usage-colors "pink dark_gray"
|
||||
```
|
||||
|
||||
## Status bar options - [up](#table-of-contents)
|
||||
|
||||
Enable window flags
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-flags true
|
||||
```
|
||||
|
||||
Adjust the refresh rate for the status bar
|
||||
|
||||
```bash
|
||||
# the default is 5, it can accept any number
|
||||
set -g @dracula-refresh-rate 5
|
||||
```
|
||||
|
||||
Enable high contrast pane border
|
||||
|
||||
```bash
|
||||
set -g @dracula-border-contrast true
|
||||
```
|
||||
|
||||
Hide empty plugins
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-empty-plugins false
|
||||
```
|
||||
|
||||
Set plugin padding
|
||||
Whilst the padding is one space per default, can be whatever you want it to be, whether that's whitespace or other characters.
|
||||
|
||||
```bash
|
||||
set -g @dracula-left-pad ' ° '
|
||||
set -g @dracula-right-pad ' ° '
|
||||
```
|
||||
|
||||
If you want to remove any padding, you can use `false` as a value.
|
||||
|
||||
```bash
|
||||
set -g @dracula-left-pad false
|
||||
set -g @dracula-right-pad false
|
||||
```
|
||||
|
||||
### Powerline - [up](#table-of-contents)
|
||||
|
||||
Enable powerline symbols
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-powerline true
|
||||
```
|
||||
|
||||
Enable edge icons
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-edge-icons true
|
||||
```
|
||||
|
||||
Switch powerline symbols
|
||||
|
||||
```bash
|
||||
# for left
|
||||
set -g @dracula-show-left-sep
|
||||
|
||||
# for right symbol (can set any symbol you like as separator)
|
||||
set -g @dracula-show-right-sep
|
||||
```
|
||||
|
||||
Make the powerline background transparent
|
||||
|
||||
```bash
|
||||
set -g @dracula-transparent-powerline-bg true
|
||||
|
||||
# the left separator symbol is inversed with a transparent background, you can modify it with any symbol you like
|
||||
set -g @dracula-inverse-divider
|
||||
```
|
||||
|
||||
### Left Icon - [up](#table-of-contents)
|
||||
|
||||
- The left icon can be set to anything static you'd like.
|
||||
- However if you use tmux on multiple machines, it may be helpful to display the hostname.
|
||||
- If you use multiple sessions simultaneously it can be good to name them and have the name in the left icon.
|
||||
|
||||
the following example uses formatting to display `"hostname | session_name"`:
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-left-icon "#h | #S"
|
||||
```
|
||||
|
||||
formats:
|
||||
|
||||
```bash
|
||||
#H: Hostname of local host
|
||||
#h: Hostname of local host (no domain name)
|
||||
#S: name of session -> suggestion: alias trs to tmux rename-session
|
||||
#W: current Window
|
||||
```
|
||||
|
||||
more formats can be found here, though those without a shorthand like #H need to be used like #{host}, which is equivalent.
|
||||
[reference: tmux(1) - OpenBSD manual pages](https://man.openbsd.org/tmux.1#FORMATS)
|
||||
|
||||
besides formats, any other string can be used.
|
||||
|
||||
additionally the left icons padding can be set like so:
|
||||
|
||||
```bash
|
||||
# default is 1, it can accept any number and 0 disables padding.
|
||||
set -g @dracula-left-icon-padding 1
|
||||
```
|
||||
|
||||
## [Color Theming](/docs/color_theming/README.md) - [up](#table-of-contents)
|
||||
|
||||
Each individual widget's foreground and background color can be overridden.
|
||||
Additionally, the variables used for storing color values can be overridden and extended.
|
||||
This allows for the use of custom themes like catppuccin or gruvbox.
|
||||
|
||||
For everything regarding colors, please refer to [the color theming directory](/docs/color_theming/README.md).
|
||||
|
||||
## Plugins
|
||||
|
||||
### attached-clients - [up](#table-of-contents)
|
||||
|
||||
This widget provides the number of clients attached to the current tmux session.
|
||||
|
||||
Set the minimum number of clients to show (otherwise, show nothing)
|
||||
|
||||
```bash
|
||||
set -g @dracula-clients-minimum 1
|
||||
```
|
||||
|
||||
Set the label when there is one client, or more than one client
|
||||
|
||||
```bash
|
||||
set -g @dracula-clients-singular client
|
||||
set -g @dracula-clients-plural clients
|
||||
```
|
||||
|
||||
### battery - [up](#table-of-contents)
|
||||
|
||||
This widget provides information about the current charge of the battery, whether it is attached to a powersupply and charging from it, or running off the powersupply without charging. it also detects desktop pcs having no battery.
|
||||
|
||||
Display any icon for the battery you'd like with:
|
||||
|
||||
```bash
|
||||
set -g @dracula-battery-label "🦇 "
|
||||
```
|
||||
|
||||
to use nothing but nerdfont icons informing you about the current state, use the following,
|
||||
which will display the battery charge and whether its charging (or just drawing from AC) as nerdfont icons.
|
||||
|
||||
```bash
|
||||
set -g @dracula-battery-label false
|
||||
set -g @dracula-show-battery-status true
|
||||
```
|
||||
these settings will introduce the following icons:
|
||||
- the battery is discharging and at the current level: `` `` `` `` `` `` `` `` `` `` ``
|
||||
- the battery is charging and at the current level: `` `` `` `` `` `` `` `` `` `` ``
|
||||
- power is being drawn from AC, but the battery is neither charging nor discharging: ``
|
||||
- we were able to determine that the battery is charging/ discharging, but something about the percentage went wrong: ``
|
||||
- we don't know the status of the battery: ``
|
||||
|
||||
if you have no battery and would like the widget to hide in that case, set the following:
|
||||
|
||||
```bash
|
||||
set -g @dracula-no-battery-label false
|
||||
```
|
||||
|
||||
alternatively, if you have no battery and would like a nerdfont icon to indicate that, consider setting the following:
|
||||
|
||||
```bash
|
||||
set -g @dracula-no-battery-label " "
|
||||
```
|
||||
|
||||
in case you have multiple batteries:
|
||||
|
||||
the default battery label is only displayed in the very front.
|
||||
you can specify multiple battery labels by splitting them with `\n` like so:
|
||||
```bash
|
||||
set -g @dracula-battery-label "1:\n2:"
|
||||
```
|
||||
additionally you can specify the separator between each battery like so:
|
||||
```bash
|
||||
set -g @dracula-battery-separator "; "
|
||||
```
|
||||
|
||||
### compact-alt - [up](#table-of-contents)
|
||||
|
||||
This widget allows the user to switch to an alternate list of widgets when the terminal becomes narrow.
|
||||
Switching only works if the widget is added to `set -g @dracula-plugins "your-plugins-here"`.
|
||||
|
||||
to set what widgets should be shown in narrow mode, set the following variable. _make sure to include the compact-alt widget as you won't be able to switch out of narrow mode otherwise._
|
||||
|
||||
```bash
|
||||
set -g @dracula-narrow-plugins "compact-alt battery network weather"
|
||||
```
|
||||
|
||||
to determine when to switch to narrow mode, set the following variable.
|
||||
any value below this threshold is considered narrow.
|
||||
|
||||
```bash
|
||||
set -g @dracula-compact-min-width 140
|
||||
```
|
||||
|
||||
the compact-alt widget needs to reload your tmux config to switch from wide to narrow and back.
|
||||
therefore, you need to make sure to set the right path to your config file.
|
||||
|
||||
```bash
|
||||
set -g @dracula-config-path "$HOME/.config/tmux/tmux.conf"
|
||||
```
|
||||
|
||||
if you want to see your window with and whether narrow mode is active, set the following, which is false per default.
|
||||
|
||||
```bash
|
||||
set -g @dracula-compact-alt-verbose true
|
||||
```
|
||||
|
||||
this widget maintains a global variable informing about whether narrow mode is active.
|
||||
that variable should never be touched by the user and could potentially be used by other widgets/ plugins.
|
||||
|
||||
```bash
|
||||
# NEVER DO:
|
||||
set -g @dracula-narrow-mode some-value
|
||||
```
|
||||
|
||||
### continuum - [up](#table-of-contents)
|
||||
|
||||
Set the output mode. Options are:
|
||||
|
||||
- **countdown**: Show a T- countdown to the next save (default)
|
||||
- **time**: Show the time since the last save
|
||||
- **alert**: Hide output if no save has been performed recently
|
||||
- **interval**: Show the continuum save interval
|
||||
|
||||
```bash
|
||||
set -g @dracula-continuum-mode countdown
|
||||
```
|
||||
|
||||
Show if the last save was performed less than 60 seconds ago (default threshold is 15 seconds)
|
||||
|
||||
```bash
|
||||
set -g @dracula-continuum-time-threshold 60
|
||||
```
|
||||
|
||||
Other options.
|
||||
|
||||
```bash
|
||||
@dracula-continuum-first-save
|
||||
@resurrect-dir
|
||||
@continuum-save-last-timestamp
|
||||
@continuum-save-interval
|
||||
```
|
||||
|
||||
### cpu-arch - [up](#table-of-contents)
|
||||
|
||||
This widget displays the cpu architecture.
|
||||
|
||||
possible nerdfont settings for cpu arch label:
|
||||
|
||||
```bash
|
||||
set -g @dracula-cpu-arch-label " "
|
||||
```
|
||||
|
||||
### cpu-usage - [up](#table-of-contents)
|
||||
|
||||
This widget displays the cpu usage in percent by default, but can display cpu load on linux.
|
||||
Load average – is the average system load calculated over a given period of time of 1, 5 and 15 minutes (output: x.x x.x x.x)
|
||||
|
||||
```bash
|
||||
set -g @dracula-cpu-display-load true
|
||||
```
|
||||
|
||||
possible nerdfont settings for cpu usage label:
|
||||
|
||||
```bash
|
||||
set -g @dracula-cpu-usage-label " "
|
||||
```
|
||||
|
||||
nerdfont icons to consider:
|
||||
|
||||
```bash
|
||||
|
||||
```
|
||||
|
||||
`set -g @dracula-refresh-rate 5` affects this widget
|
||||
|
||||
### cwd - [up](#table-of-contents)
|
||||
|
||||
This widget displays the path of the current working directory, where the path of the users home directory will be shortened to `~`.
|
||||
|
||||
The maximum number of directories and number of characters used for that is unlimited by default, but can be set with the following two options:
|
||||
|
||||
```bash
|
||||
set -g @dracula-cwd-max-dirs "0"
|
||||
set -g @dracula-cwd-max-chars "0"
|
||||
```
|
||||
|
||||
### fossil - [up](#table-of-contents)
|
||||
|
||||
Fossil has no configurable options
|
||||
|
||||
### git - [up](#table-of-contents)
|
||||
|
||||
This widget displays info about the current git repository.
|
||||
|
||||
Hide details of git changes
|
||||
|
||||
```bash
|
||||
set -g @dracula-git-disable-status true
|
||||
```
|
||||
|
||||
Set symbol to use for when branch is up to date with HEAD
|
||||
|
||||
```bash
|
||||
# default is ✓. Avoid using non unicode characters that bash uses like $, * and !
|
||||
set -g @dracula-git-show-current-symbol ✓
|
||||
```
|
||||
|
||||
Set symbol to use for when branch diverges from HEAD
|
||||
|
||||
```bash
|
||||
# default is unicode !. Avoid bash special characters
|
||||
set -g @dracula-git-show-diff-symbol !
|
||||
```
|
||||
|
||||
Set symbol or message to use when the current pane has no git repo
|
||||
|
||||
```bash
|
||||
# default is unicode no message
|
||||
set -g @dracula-git-no-repo-message ""
|
||||
```
|
||||
|
||||
Hide untracked files from being displayed as local changes
|
||||
|
||||
```bash
|
||||
# default is false
|
||||
set -g @dracula-git-no-untracked-files true
|
||||
```
|
||||
|
||||
Show remote tracking branch together with diverge/sync state
|
||||
|
||||
```bash
|
||||
# default is false
|
||||
set -g @dracula-git-show-remote-status true
|
||||
```
|
||||
|
||||
Show the current repository name in the status bar
|
||||
```bash
|
||||
# default is false
|
||||
set -g @dracula-git-show-repo-name true
|
||||
```
|
||||
|
||||
Limit the maximum length of git branch names displayed in the status bar. Truncation is disabled by default.
|
||||
```bash
|
||||
set -g @dracula-git-truncate-length 10
|
||||
```
|
||||
|
||||
### gpu-info - [up](#table-of-contents)
|
||||
|
||||
These widgets display the current computational, ram, and power usage of installed graphics cards.
|
||||
They are split into widgets with the names: `gpu-usage, gpu-ram-usage, gpu-power-draw`.
|
||||
|
||||
hardware support:
|
||||
|
||||
- full support for NVIDIA gpus on linux, when using official nvidia drivers.
|
||||
- partial support for apple m-chips on MacOS.
|
||||
- partial support for amd and intel on linux
|
||||
|
||||
If your gpu is not recognised, force the script to assume a certain brand.
|
||||
|
||||
```bash
|
||||
set -g @dracula-force-gpu "NVIDIA"
|
||||
```
|
||||
|
||||
To display the used vram in percent (gigabyte is default unit):
|
||||
|
||||
```bash
|
||||
set -g @dracula-gpu-vram-percent true
|
||||
```
|
||||
|
||||
Vram usage is displayed in gigabyte without decimal places per default. To change that behaviour, use the following options with the respective number of decimal places you'd like to get:
|
||||
|
||||
```bash
|
||||
set -g @dracula-gpu-vram-used-accuracy ".2f"
|
||||
set -g @dracula-gpu-vram-total-accuracy ".1f"
|
||||
```
|
||||
|
||||
To display the power usage in percent (watt is default unit):
|
||||
|
||||
```bash
|
||||
set -g @dracula-gpu-power-percent true
|
||||
```
|
||||
|
||||
Possible nerdfont settings for gpu info labels:
|
||||
|
||||
```bash
|
||||
set -g @dracula-gpu-power-label " "
|
||||
set -g @dracula-gpu-usage-label " "
|
||||
set -g @dracula-gpu-vram-label " "
|
||||
```
|
||||
|
||||
nerdfont icons to consider:
|
||||
|
||||
```bash
|
||||
|
||||
```
|
||||
|
||||
`set -g @dracula-refresh-rate 5` affects this widget
|
||||
|
||||
### hg - [up](#table-of-contents)
|
||||
|
||||
This widget displays info about the current mercurial repository.
|
||||
|
||||
Hide details of hg changes
|
||||
|
||||
```bash
|
||||
set -g @dracula-hg-disable-status true
|
||||
```
|
||||
|
||||
Set symbol to use for when branch is up to date with HEAD
|
||||
|
||||
```bash
|
||||
#default is ✓.Avoid using non unicode characters that bash uses like $, * and !
|
||||
set -g @dracula-hg-show-current-symbol ✓
|
||||
```
|
||||
|
||||
Set symbol to use for when branch diverges from HEAD
|
||||
|
||||
```bash
|
||||
#default is unicode !.Avoid bash special characters
|
||||
set -g @dracula-hg-show-diff-symbol !
|
||||
```
|
||||
|
||||
Set symbol or message to use when the current pane has no hg repo
|
||||
|
||||
```bash
|
||||
#default is unicode no message
|
||||
set -g @dracula-hg-no-repo-message ""
|
||||
```
|
||||
|
||||
Hide untracked files from being displayed as local changes
|
||||
|
||||
```bash
|
||||
#default is false
|
||||
set -g @dracula-hg-no-untracked-files false
|
||||
```
|
||||
|
||||
### Kerberos TGT - [up](#table-of-contents)
|
||||
|
||||
This widgets name is `krbtgt`.
|
||||
|
||||
Set the principal to check the TGT expiration date for (with or without the REALM)
|
||||
|
||||
```
|
||||
set -g @dracula-krbtgt-principal "principal"
|
||||
```
|
||||
|
||||
### kubernetes-context - [up](#table-of-contents)
|
||||
|
||||
Add prefix label before the context
|
||||
|
||||
```bash
|
||||
set -g @dracula-kubernetes-context-label "Some Label"
|
||||
```
|
||||
|
||||
Hide user from the context string
|
||||
|
||||
```bash
|
||||
set -g @dracula-kubernetes-hide-user true
|
||||
```
|
||||
|
||||
Hide ARN (show only cluster name) - Available for EKS only (only available for cluster names that are ARNs)
|
||||
|
||||
```bash
|
||||
set -g @dracula-kubernetes-eks-hide-arn true
|
||||
```
|
||||
|
||||
Extract the account as a prefix to the cluster name - Available for EKS only (only available for cluster names that are ARNs)
|
||||
|
||||
```bash
|
||||
set -g @dracula-kubernetes-eks-extract-account true
|
||||
```
|
||||
|
||||
Combine the above options and show only the Kubernetes Context
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-only-kubernetes-context true
|
||||
```
|
||||
|
||||
Hide empty plugin when the `~/.kube/config` file is missing
|
||||
|
||||
```bash
|
||||
set -g @dracula-kubernetes-hide-no-config true
|
||||
```
|
||||
|
||||
### libreview - [up](#table-of-contents)
|
||||
|
||||
This script retrieves and displays continuous glucose monitoring (CGM) data from the LibreView API.
|
||||
It caches the data to minimize API requests and displays the latest glucose level along with a trend indicator in a Tmux status bar.
|
||||
|
||||
### mac-player - [up](#table-of-contents)
|
||||
|
||||
This widget and script displays music information provided by the native macOS players.
|
||||
|
||||
The current supported apps are:
|
||||
|
||||
- Native Players:
|
||||
- Spotify
|
||||
- Music - Apple Music
|
||||
- Browser Players (active tab must match one of these URLs and requires Google Chrome or Safari):
|
||||
- youtube.com/watch
|
||||
- open.spotify.com
|
||||
|
||||
It also has a remote-player feature.
|
||||
The supported remote players are:
|
||||
|
||||
- Spotify
|
||||
- Music - Apple Music
|
||||
|
||||
To change player icons:
|
||||
|
||||
```bash
|
||||
set -g @dracula-mac-player-play-icon "♪ "
|
||||
set -g @dracula-mac-player-pause-icon "❚❚ "
|
||||
|
||||
```
|
||||
|
||||
To change length of the widget (length 25 by default):
|
||||
|
||||
```bash
|
||||
set -g @dracula-mac-player-length 25
|
||||
```
|
||||
|
||||
To activate the remote:
|
||||
|
||||
```bash
|
||||
set -g @dracula-mac-player-remote true
|
||||
```
|
||||
|
||||
To specify the app to use(`"Music"` or `"Spotify"`):
|
||||
|
||||
```bash
|
||||
set -g @dracula-mac-player-app "Music"
|
||||
```
|
||||
|
||||
The default keybinds are:
|
||||
|
||||
- `<prefix> + P` - Play/Pause
|
||||
- `<prefix> + R` - Back to position 0/previous track
|
||||
- `<prefix> + N` - Next track
|
||||
|
||||
To change the keybinds:
|
||||
|
||||
```bash
|
||||
set -g @dracula-mac-player-remote-play-pause "P"
|
||||
set -g @dracula-mac-player-remote-back "R"
|
||||
set -g @dracula-mac-player-remote-next "N"
|
||||
```
|
||||
|
||||
### mpc - [up](#table-of-contents)
|
||||
|
||||
This widget displays music information provided by mpc.
|
||||
|
||||
To format the display format:
|
||||
|
||||
```bash
|
||||
set -g @dracula-mpc-format "%title% - %artist%"
|
||||
```
|
||||
|
||||
`set -g @dracula-refresh-rate 5` affects this widget
|
||||
|
||||
### network - [up](#table-of-contents)
|
||||
|
||||
This widget displays one of three states: offline, ethernet connected, or wifi connected.
|
||||
however, per default **this will only display the wifi you're connected to, if it provides internet access!**
|
||||
|
||||
You can use different hosts to ping in order to check for a wifi or wired connection.
|
||||
If you frequently use networks without internet access, you can use local ip-addresses here to still display the connection.
|
||||
|
||||
```bash
|
||||
set -g @dracula-network-hosts "1.1.1.1 8.8.8.8"
|
||||
```
|
||||
|
||||
Possible nerdfont settings for network info:
|
||||
|
||||
```bash
|
||||
set -g @dracula-network-ethernet-label " Eth"
|
||||
set -g @dracula-network-offline-label " "
|
||||
set -g @dracula-network-wifi-label " "
|
||||
```
|
||||
|
||||
Nerdfont icons to consider:
|
||||
|
||||
```
|
||||
ethernet:
|
||||
offline:
|
||||
wifi:
|
||||
```
|
||||
|
||||
Known issues:
|
||||
|
||||
- If for some reason `iw` is only in the path for root and not the normal user, wifi connections will be considered ethernet connections.
|
||||
|
||||
### network-public-ip - [up](#table-of-contents)
|
||||
|
||||
This widget displays the public IP address you're using, by querying the public service `ifconfig.me`.
|
||||
|
||||
Possible nerdfont settings for public IP info:
|
||||
|
||||
```bash
|
||||
set -g @dracula-network-public-ip-label " "
|
||||
```
|
||||
|
||||
### network-bandwidth - [up](#table-of-contents)
|
||||
|
||||
This widget gives the currently used up and download speeds per second for one interface.
|
||||
|
||||
The most common interfaces name are `eth0` for a wired connection and `wlan0` for a wireless connection.
|
||||
To set a specific network interface you'd like to monitor, used:
|
||||
|
||||
```bash
|
||||
set -g @dracula-network-bandwidth "eno0"
|
||||
```
|
||||
|
||||
To display the interface name alongside the speeds, set:
|
||||
|
||||
```bash
|
||||
set -g @dracula-network-bandwidth-show-interface true
|
||||
```
|
||||
|
||||
Per default, this widget checks the speeds as frequently as it can. to set longer intervals, use the following:
|
||||
|
||||
```bash
|
||||
set -g @dracula-network-bandwidth-interval 5
|
||||
```
|
||||
|
||||
### network-ping - [up](#table-of-contents)
|
||||
|
||||
This widget displays the current ping to a specific server.
|
||||
|
||||
You can configure which server (hostname, IP) you want to ping and at which rate (in seconds). Default is google.com at every 5 seconds.
|
||||
|
||||
```bash
|
||||
set -g @dracula-ping-server "google.com"
|
||||
set -g @dracula-ping-rate 5
|
||||
```
|
||||
|
||||
### network-vpn - [up](#table-of-contents)
|
||||
|
||||
This widget tries to display whether a vpn is connected.
|
||||
Tailscale exit nodes are fully supported for Linux and MacOS.
|
||||
|
||||
Set verbose to true in order to see the VPNs IP or name of Tailscale exit node.
|
||||
|
||||
```bash
|
||||
set -g @dracula-network-vpn-verbose true
|
||||
```
|
||||
|
||||
Set the widgets label like so:
|
||||
```bash
|
||||
set -g @dracula-network-vpn-label " "
|
||||
```
|
||||
|
||||
### playerctl - [up](#table-of-contents)
|
||||
|
||||
This widget displays playerctl info.
|
||||
|
||||
Set the playerctl metadata format like so:
|
||||
|
||||
```bash
|
||||
set -g @dracula-playerctl-format "► {{ artist }} - {{ title }}"
|
||||
```
|
||||
|
||||
### ram-usage - [up](#table-of-contents)
|
||||
|
||||
This widget displays the currently used ram as GB per GB.
|
||||
|
||||
Possible nerdfont settings for ram usage:
|
||||
|
||||
```bash
|
||||
set -g @dracula-ram-usage-label " "
|
||||
```
|
||||
|
||||
Nerdfont icons to consider:
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### spotify-tui - [up](#table-of-contents)
|
||||
|
||||
This widget displays music information provided by spotify-tui. Spotify-tui must be installed to use this widget.
|
||||
|
||||
To format the display format:
|
||||
|
||||
```bash
|
||||
set -g @dracula-spotify-tui-format "%f %s %t - %a"
|
||||
```
|
||||
|
||||
To limit the maximum length (0 means unlimited length):
|
||||
|
||||
```bash
|
||||
set -g @dracula-spotify-tui-max-len 30
|
||||
```
|
||||
|
||||
`set -g @dracula-refresh-rate 5` affects this widget
|
||||
|
||||
### spr - [up](#table-of-contents)
|
||||
|
||||
This widget displays music information provided by [spotify-player](https://github.com/aome510/spotify-player). spotify-player must be installed to use this widget.
|
||||
|
||||
To change player icons:
|
||||
|
||||
```bash
|
||||
set -g @dracula-spr-play-icon "♪ "
|
||||
set -g @dracula-spr-pause-icon "❚❚ "
|
||||
|
||||
```
|
||||
|
||||
This section includes an experimental remote control feature, but it may limit the widget’s display on macOS.
|
||||
|
||||
In order to utilize the remote feature you need to install the [spotify-player-daemon](https://github.com/aome510/spotify-player#daemon)
|
||||
To activate the remote:
|
||||
|
||||
```bash
|
||||
set -g @dracula-spr-remote true
|
||||
```
|
||||
|
||||
The default keybinds are:
|
||||
|
||||
- `<prefix> + P` - Play/Pause
|
||||
- `<prefix> + R` - Back to position 0/previous track
|
||||
- `<prefix> + N` - Next track
|
||||
|
||||
To change the keybinds:
|
||||
|
||||
```bash
|
||||
set -g @dracula-spr-remote-play-pause "P"
|
||||
set -g @dracula-spr-remote-back "R"
|
||||
set -g @dracula-spr-remote-next "N"
|
||||
```
|
||||
|
||||
`set -g @dracula-refresh-rate 5` affects this widget
|
||||
|
||||
### ssh-session - [up](#table-of-contents)
|
||||
|
||||
This widget displays the current username@host combination, both of the local machine as well as when connected via ssh.
|
||||
|
||||
To output nothing (and maybe hide the widget) when not connected via ssh:
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-ssh-only-when-connected true
|
||||
```
|
||||
|
||||
Show SSH session port:
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-ssh-session-port true
|
||||
```
|
||||
|
||||
nerdfont icons to consider:
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### synchronize-panes - [up](#table-of-contents)
|
||||
|
||||
This widget displays whether the tmux panes are currently synchronised.
|
||||
|
||||
To change the label:
|
||||
|
||||
```bash
|
||||
set -g @dracula-synchronize-panes-label "Sync"
|
||||
```
|
||||
|
||||
The global refresh rate affects this widget:
|
||||
|
||||
```bash
|
||||
set -g @dracula-refresh-rate 5
|
||||
```
|
||||
|
||||
You can set a custom refresh rate just for synchronize-panes:
|
||||
|
||||
```bash
|
||||
set -g @dracula-synchronize-panes-refresh-rate "0.5" # default: unset
|
||||
```
|
||||
|
||||
**Note:** This only takes precedence for the synchronize-panes widget. This means it won't
|
||||
override the global `@dracula-refresh-rate`.
|
||||
|
||||
Alternatively, you can automatically hide the label when sync is `off`:
|
||||
|
||||
```bash
|
||||
set -g @dracula-synchronize-panes-auto-hide true # default: false
|
||||
```
|
||||
|
||||
### sys-temp - [up](#table-of-contents)
|
||||
|
||||
This widget displays the system temperature.
|
||||
|
||||
### terraform - [up](#table-of-contents)
|
||||
|
||||
Add prefix label before workspace
|
||||
|
||||
```bash
|
||||
set -g @dracula-terraform-label ""
|
||||
```
|
||||
|
||||
To use a Terraform fork like `tofu`
|
||||
|
||||
```bash
|
||||
set -g @dracula-terraform-fork "tofu"
|
||||
```
|
||||
|
||||
To hide the plugin when a `.terraform` isn't present
|
||||
|
||||
```bash
|
||||
set -g @dracula-terraform-hide true
|
||||
```
|
||||
|
||||
`set -g @dracula-refresh-rate 5` affects this widget
|
||||
|
||||
### time - [up](#table-of-contents)
|
||||
|
||||
This widget displays current date and time.
|
||||
|
||||
Disable timezone
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-timezone false
|
||||
```
|
||||
|
||||
Swap date to day/month
|
||||
|
||||
```bash
|
||||
set -g @dracula-day-month true
|
||||
```
|
||||
|
||||
Enable military time
|
||||
|
||||
```bash
|
||||
set -g @dracula-military-time true
|
||||
```
|
||||
|
||||
Set custom time format e.g (2023-01-01 14:00)
|
||||
|
||||
```bash
|
||||
set -g @dracula-time-format "%F %R"
|
||||
```
|
||||
|
||||
See [[this page]](https://man7.org/linux/man-pages/man1/date.1.html) for other format symbols.
|
||||
|
||||
### tmux-ram-usage - [up](#table-of-contents)
|
||||
|
||||
This widget displays the ram currently used by tmux.
|
||||
|
||||
Possible nerdfont settings for tmux ram usage:
|
||||
|
||||
```
|
||||
@dracula-tmux-ram-usage-label " "
|
||||
```
|
||||
|
||||
Nerdfont icons to consider:
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
### uptime - [up](#table-of-contents)
|
||||
|
||||
Shows how long the system has been running.
|
||||
|
||||
Possible nerdfont settings for uptime:
|
||||
|
||||
```
|
||||
@dracula-uptime-label " "
|
||||
```
|
||||
|
||||
### weather - [up](#table-of-contents)
|
||||
|
||||
Show weather information for given location.
|
||||
|
||||
Switch from default fahrenheit to celsius
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-fahrenheit false
|
||||
```
|
||||
|
||||
Set your location manually
|
||||
|
||||
```bash
|
||||
set -g @dracula-fixed-location "Some City"
|
||||
```
|
||||
|
||||
Hide your location
|
||||
|
||||
```bash
|
||||
set -g @dracula-show-location false
|
||||
```
|
||||
Hide the weather plugin output when an error occurs (prints an empty string instead of "Weather Unavailable" / "Unknown Location").
|
||||
This is especially useful together with `set -g @dracula-show-empty-plugins false`.
|
||||
|
||||
```bash
|
||||
set -g @dracula-weather-hide-errors true
|
||||
```
|
||||
|
||||
### custom:script-name - [up](#table-of-contents)
|
||||
|
||||
For testing/ running custom plugins, put the bash script into the scripts directory of dracula/tmux plugin.
|
||||
Additionally, in the `@dracula-plugins` option, add the script as `custom:name-of-script.sh`.
|
||||
65
data/tmux/plugins/tmux/docs/color_theming/README.md
Normal file
65
data/tmux/plugins/tmux/docs/color_theming/README.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# overriding widget colors
|
||||
widget color options with default values - sorted alphabetically:
|
||||
```
|
||||
set -g @dracula-attached-clients-colors "cyan dark_gray"
|
||||
set -g @dracula-battery-colors "pink dark_gray"
|
||||
set -g @dracula-continuum-colors "cyan dark_gray"
|
||||
set -g @dracula-cpu-usage-colors "orange dark_gray"
|
||||
set -g @dracula-custom-plugin-colors "cyan dark_gray"
|
||||
set -g @dracula-cwd-colors "dark_gray white"
|
||||
set -g @dracula-fossil-colors "green dark_gray"
|
||||
set -g @dracula-git-colors "green dark_gray"
|
||||
set -g @dracula-gpu-power-draw-colors "green dark_gray"
|
||||
set -g @dracula-gpu-ram-usage-colors "cyan dark_gray"
|
||||
set -g @dracula-gpu-usage-colors "pink dark_gray"
|
||||
set -g @dracula-hg-colors "green dark_gray"
|
||||
set -g @dracula-kubernetes-context-colors "cyan dark_gray"
|
||||
set -g @dracula-libre-colors "white dark_gray"
|
||||
set -g @dracula-mpc-colors "green dark_gray"
|
||||
set -g @dracula-network-bandwidth-colors "cyan dark_gray"
|
||||
set -g @dracula-network-colors "cyan dark_gray"
|
||||
set -g @dracula-network-ping-colors "cyan dark_gray"
|
||||
set -g @dracula-network-vpn-colors "cyan dark_gray"
|
||||
set -g @dracula-playerctl-colors "green dark_gray"
|
||||
set -g @dracula-ram-usage-colors "cyan dark_gray"
|
||||
set -g @dracula-spotify-tui-colors "green dark_gray"
|
||||
set -g @dracula-ssh-session-colors "green dark_gray"
|
||||
set -g @dracula-synchronize-panes-colors "cyan dark_gray"
|
||||
set -g @dracula-terraform-colors "light_purple dark_gray"
|
||||
set -g @dracula-time-colors "dark_purple white"
|
||||
set -g @dracula-tmux-ram-usage-colors "cyan dark_gray"
|
||||
set -g @dracula-weather-colors "orange dark_gray"
|
||||
```
|
||||
|
||||
# overriding color variables
|
||||
|
||||
all dracula colors can be overridden and new variables can be added.
|
||||
use the `set -g @dracula-colors "color variables go here"` option. put each new variable on a new line for readability or all variables on one line to save space.
|
||||
|
||||
for a quick setup, add one of the following options to your config:
|
||||
**better readability**
|
||||
```
|
||||
set -g @dracula-colors "
|
||||
# Dracula Color Pallette
|
||||
white='#f8f8f2'
|
||||
gray='#44475a'
|
||||
dark_gray='#282a36'
|
||||
light_purple='#bd93f9'
|
||||
dark_purple='#6272a4'
|
||||
cyan='#8be9fd'
|
||||
green='#50fa7b'
|
||||
orange='#ffb86c'
|
||||
red='#ff5555'
|
||||
pink='#ff79c6'
|
||||
yellow='#f1fa8c'
|
||||
"
|
||||
```
|
||||
**saving space**
|
||||
```
|
||||
set -g @dracula-colors " white='#f8f8f2' gray='#44475a' dark_gray='#282a36' light_purple='#bd93f9' dark_purple='#6272a4' cyan='#8be9fd' green='#50fa7b' orange='#ffb86c' red='#ff5555' pink='#ff79c6' yellow='#f1fa8c' "
|
||||
```
|
||||
## plug and play themes
|
||||
as part of this directory there are some plug and play themes with explanations on how to use them:
|
||||
- [catppuccin](/docs/color_theming/catppuccin.md)
|
||||
- [gruvbox](/docs/color_theming/gruvbox.md)
|
||||
- [tomorrow night](/docs/color_theming/tomorrow_night.md)
|
||||
176
data/tmux/plugins/tmux/docs/color_theming/catppuccin.md
Normal file
176
data/tmux/plugins/tmux/docs/color_theming/catppuccin.md
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
# drac to cat
|
||||
|
||||
|
||||
for a quick setup, set the following option:
|
||||
```
|
||||
set -g @dracula-colors "
|
||||
# simple catppuccin Color Pallette
|
||||
pink='#cba6f7'
|
||||
orange='#fab387'
|
||||
yellow='#f9e2af'
|
||||
green='#a6e3a1'
|
||||
cyan='#89dceb'
|
||||
light_purple='#b4befe'
|
||||
white='#cdd6f4'
|
||||
dark_gray='#313244'
|
||||
red='#f38ba8'
|
||||
gray='#45475a'
|
||||
dark_purple='#6c7086'
|
||||
"
|
||||
```
|
||||
|
||||
|
||||
alternatively use the full catppuccin color palette and customise the flags accordingly
|
||||
|
||||
# catppuccin Color Pallette
|
||||
|
||||
# latte
|
||||
```
|
||||
Rosewater='#dc8a78'
|
||||
Flamingo='#dd7878'
|
||||
Pink='#ea76cb'
|
||||
Mauve='#8839ef'
|
||||
Red='#d20f39'
|
||||
Maroon='#e64553'
|
||||
Peach='#fe640b'
|
||||
Yellow='#df8e1d'
|
||||
Green='#40a02b'
|
||||
Teal='#179299'
|
||||
Sky='#04a5e5'
|
||||
Sapphire='#209fb5'
|
||||
Blue='#1e66f5'
|
||||
Lavender='#7287fd'
|
||||
Text='#4c4f69'
|
||||
Subtext1='#5c5f77'
|
||||
Subtext0='#6c6f85'
|
||||
Overlay2='#7c7f93'
|
||||
Overlay1='#8c8fa1'
|
||||
Overlay0='#9ca0b0'
|
||||
Surface2='#acb0be'
|
||||
Surface1='#bcc0cc'
|
||||
Surface0='#ccd0da'
|
||||
Base='#eff1f5'
|
||||
Mantle='#e6e9ef'
|
||||
Crust='#dce0e8'
|
||||
```
|
||||
|
||||
# frappe
|
||||
```
|
||||
Rosewater='#f2d5cf'
|
||||
Flamingo='#eebebe'
|
||||
Pink='#f4b8e4'
|
||||
Mauve='#ca9ee6'
|
||||
Red='#e78284'
|
||||
Maroon='#ea999c'
|
||||
Peach='#ef9f76'
|
||||
Yellow='#e5c890'
|
||||
Green='#a6d189'
|
||||
Teal='#81c8be'
|
||||
Sky='#99d1db'
|
||||
Sapphire='#85c1dc'
|
||||
Blue='#8caaee'
|
||||
Lavender='#babbf1'
|
||||
Text='#c6d0f5'
|
||||
Subtext1='#b5bfe2'
|
||||
Subtext0='#a5adce'
|
||||
Overlay2='#949cbb'
|
||||
Overlay1='#838ba7'
|
||||
Overlay0='#737994'
|
||||
Surface2='#626880'
|
||||
Surface1='#51576d'
|
||||
Surface0='#414559'
|
||||
Base='#303446'
|
||||
Mantle='#292c3c'
|
||||
Crust='#232634'
|
||||
```
|
||||
|
||||
# macchiato
|
||||
```
|
||||
Rosewater='#f4dbd6'
|
||||
Flamingo='#f0c6c6'
|
||||
Pink='#f5bde6'
|
||||
Mauve='#c6a0f6'
|
||||
Red='#ed8796'
|
||||
Maroon='#ee99a0'
|
||||
Peach='#f5a97f'
|
||||
Yellow='#eed49f'
|
||||
Green='#a6da95'
|
||||
Teal='#8bd5ca'
|
||||
Sky='#91d7e3'
|
||||
Sapphire='#7dc4e4'
|
||||
Blue='#8aadf4'
|
||||
Lavender='#b7bdf8'
|
||||
Text='#cad3f5'
|
||||
Subtext1='#b8c0e0'
|
||||
Subtext0='#a5adcb'
|
||||
Overlay2='#939ab7'
|
||||
Overlay1='#8087a2'
|
||||
Overlay0='#6e738d'
|
||||
Surface2='#5b6078'
|
||||
Surface1='#494d64'
|
||||
Surface0='#363a4f'
|
||||
Base='#24273a'
|
||||
Mantle='#1e2030'
|
||||
Crust='#181926'
|
||||
```
|
||||
|
||||
# mocha
|
||||
```
|
||||
Rosewater='#f5e0dc'
|
||||
Flamingo='#f2cdcd'
|
||||
Pink='#f5c2e7'
|
||||
Mauve='#cba6f7'
|
||||
Red='#f38ba8'
|
||||
Maroon='#eba0ac'
|
||||
Peach='#fab387'
|
||||
Yellow='#f9e2af'
|
||||
Green='#a6e3a1'
|
||||
Teal='#94e2d5'
|
||||
Sky='#89dceb'
|
||||
Sapphire='#74c7ec'
|
||||
Blue='#89b4fa'
|
||||
Lavender='#b4befe'
|
||||
Text='#cdd6f4'
|
||||
Subtext1='#bac2de'
|
||||
Subtext0='#a6adc8'
|
||||
Overlay2='#9399b2'
|
||||
Overlay1='#7f849c'
|
||||
Overlay0='#6c7086'
|
||||
Surface2='#585b70'
|
||||
Surface1='#45475a'
|
||||
Surface0='#313244'
|
||||
Base='#1e1e2e'
|
||||
Mantle='#181825'
|
||||
Crust='#11111b'
|
||||
```
|
||||
|
||||
# TODO: check em all
|
||||
```
|
||||
set -g "@dracula-cwd-colors" "Surface0 Text"
|
||||
set -g "@dracula-fossil-colors" "Green Surface0"
|
||||
set -g "@dracula-git-colors" "Green Surface0"
|
||||
set -g "@dracula-hg-colors" "Green Surface0"
|
||||
set -g "@dracula-battery-colors" "Mauve Surface0"
|
||||
set -g "@dracula-gpu-usage-colors" "Mauve Surface0"
|
||||
set -g "@dracula-gpu-ram-usage-colors" "Sky Surface0"
|
||||
set -g "@dracula-gpu-power-draw-colors" "Green Surface0"
|
||||
set -g "@dracula-cpu-usage-colors" "orange Surface0"
|
||||
set -g "@dracula-ram-usage-colors" "Sky Surface0"
|
||||
set -g "@dracula-tmux-ram-usage-colors" "Sky Surface0"
|
||||
set -g "@dracula-network-colors" "Sky Surface0"
|
||||
set -g "@dracula-network-bandwidth-colors" "Sky Surface0"
|
||||
set -g "@dracula-network-ping-colors" "Sky Surface0"
|
||||
set -g "@dracula-network-vpn-colors" "Sky Surface0"
|
||||
set -g "@dracula-attached-clients-colors" "Sky Surface0"
|
||||
set -g "@dracula-mpc-colors" "Green Surface0"
|
||||
set -g "@dracula-spotify-tui-colors" "Green Surface0"
|
||||
set -g "@dracula-playerctl-colors" "Green Surface0"
|
||||
set -g "@dracula-kubernetes-context-colors" "Sky Surface0"
|
||||
set -g "@dracula-terraform-colors" "Lavender Surface0"
|
||||
set -g "@dracula-continuum-colors" "Sky Surface0"
|
||||
set -g "@dracula-weather-colors" "orange Surface0"
|
||||
set -g "@dracula-time-colors" "dark_purple white"
|
||||
set -g "@dracula-synchronize-panes-colors" "Sky Surface0"
|
||||
set -g "@dracula-libre-colors" "Text Surface0"
|
||||
set -g "@dracula-ssh-session-colors" "Green Surface0"
|
||||
```
|
||||
97
data/tmux/plugins/tmux/docs/color_theming/gruvbox.md
Normal file
97
data/tmux/plugins/tmux/docs/color_theming/gruvbox.md
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
# drac to gruv
|
||||
|
||||
for a quick setup, set the following option:
|
||||
```
|
||||
set -g @dracula-colors "
|
||||
# simple gruvbox Color Pallette
|
||||
white='#EBDBB2'
|
||||
gray='#32302F'
|
||||
dark_gray='#282828'
|
||||
light_purple='#B16286'
|
||||
dark_purple='#504945'
|
||||
cyan='#689D6A'
|
||||
green='#98971A'
|
||||
orange='#D65D0E'
|
||||
red='#CC241D'
|
||||
pink='#D3869B'
|
||||
yellow='#D79921'
|
||||
"
|
||||
```
|
||||
|
||||
alternatively use the full gruvbox color palette and customise the flags accordingly
|
||||
|
||||
# GruvBox Color Pallette
|
||||
## dark
|
||||
```
|
||||
# === colors ===
|
||||
# --- muted ---
|
||||
muted_back="#282828"
|
||||
muted_red="#CC241D"
|
||||
muted_green="#98971A"
|
||||
muted_yellow="#D79921"
|
||||
muted_blue="#458588"
|
||||
muted_purple="#B16286"
|
||||
muted_aqua="#689D6A"
|
||||
muted_orange="#D65D0E"
|
||||
muted_fore="#A89984"
|
||||
# --- strong ---
|
||||
strong_back="#928374"
|
||||
strong_red="#FB4934"
|
||||
strong_green="#B8BB26"
|
||||
strong_yellow="#FABD2F"
|
||||
strong_blue="#83A598"
|
||||
strong_purple="#D3869B"
|
||||
strong_aqua="#8EC07C"
|
||||
strong_orange="#FE8019"
|
||||
strong_fore="#EBDBB2"
|
||||
# === backgrounds ===
|
||||
back_0_hard="#1D2021"
|
||||
back_0_soft="#32302F"
|
||||
back_1="#3C3836"
|
||||
back_2="#504945"
|
||||
back_3="#665C54"
|
||||
back_4="#7C6F64"
|
||||
fore_0_hard="#FBF1C7"
|
||||
fore_0_soft="#FBF1C7"
|
||||
fore_1="#EBDBB2"
|
||||
fore_2="#D5C4A1"
|
||||
fore_3="#BDAE93"
|
||||
fore_4="#A89984"
|
||||
```
|
||||
## light
|
||||
```
|
||||
# === colors ===
|
||||
# --- muted ---
|
||||
muted_back="#FBF1C7"
|
||||
muted_red="#CC241D"
|
||||
muted_green="#98971A"
|
||||
muted_yellow="#D79921"
|
||||
muted_blue="#458588"
|
||||
muted_purple="#B16286"
|
||||
muted_aqua="#689D6A"
|
||||
muted_orange="#D65D0E"
|
||||
muted_fore="#7C6F64"
|
||||
# --- strong ---
|
||||
strong_back="#928374"
|
||||
strong_red="#9d0006"
|
||||
strong_green="#79740E"
|
||||
strong_yellow="#B57614"
|
||||
strong_blue="#076678"
|
||||
strong_purple="#8F3F71"
|
||||
strong_aqua="#427B58"
|
||||
strong_orange="#AF3A03"
|
||||
strong_fore="#3C3836"
|
||||
# === backgrounds ===
|
||||
back_0_hard="#F9F5D7"
|
||||
back_0_soft="#F2E5BC"
|
||||
back_1="#EBDBB2"
|
||||
back_2="#D5C4A1"
|
||||
back_3="#BDAE93"
|
||||
back_4="#A89984"
|
||||
fore_0_hard="#282828"
|
||||
fore_0_soft="#282828"
|
||||
fore_1="#3C3836"
|
||||
fore_2="#504945"
|
||||
fore_3="#665C54"
|
||||
fore_4="#7C6F64"
|
||||
```
|
||||
19
data/tmux/plugins/tmux/docs/color_theming/kanagawa.md
Normal file
19
data/tmux/plugins/tmux/docs/color_theming/kanagawa.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# drac to [kanagawa](https://github.com/rebelot/kanagawa.nvim)
|
||||
for a quick setup, set the following options:
|
||||
|
||||
```tmux
|
||||
# kanagawa
|
||||
set -g @dracula-colors "
|
||||
white='#dcd7ba'
|
||||
gray='#2a2a37'
|
||||
dark_gray='#363646'
|
||||
light_purple='#363646'
|
||||
dark_purple='#54546D'
|
||||
cyan='#6a9589'
|
||||
green='#938aa9'
|
||||
orange='#dca561'
|
||||
red='#e46876'
|
||||
pink='#d27e99'
|
||||
yellow='#ff9e3b'
|
||||
"
|
||||
```
|
||||
22
data/tmux/plugins/tmux/docs/color_theming/monokai_pro.md
Normal file
22
data/tmux/plugins/tmux/docs/color_theming/monokai_pro.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Drac to Monokai Pro
|
||||
|
||||
For a quick setup, set the following options:
|
||||
|
||||
```tmux
|
||||
# Monokai Pro
|
||||
set -g @dracula-colors "
|
||||
white='#fcfcfa'
|
||||
gray='#403e41'
|
||||
dark_gray='#2d2a2e'
|
||||
light_purple='#ab9df2'
|
||||
dark_purple='#5b595c'
|
||||
cyan='#78dce8'
|
||||
green='#a9dc76'
|
||||
orange='#fc9867'
|
||||
red='#ff6188'
|
||||
pink='#ff79c6'
|
||||
yellow='#ffd866'
|
||||
"
|
||||
```
|
||||
|
||||
Based on [maxpetretta/tmux-monokai-pro](https://github.com/maxpetretta/tmux-monokai-pro)
|
||||
106
data/tmux/plugins/tmux/docs/color_theming/tomorrow_night.md
Normal file
106
data/tmux/plugins/tmux/docs/color_theming/tomorrow_night.md
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
# drac to tomorrow night
|
||||
|
||||
for a quick setup, set the following option:
|
||||
```
|
||||
set -g @dracula-colors "
|
||||
# simple tomorrow night color palette
|
||||
pink='#cc6666'
|
||||
orange='#de935f'
|
||||
yellow='#f0c574'
|
||||
green='#b5bd68'
|
||||
cyan='#8abdb6'
|
||||
blue='#81a2be'
|
||||
light_purple='#b294ba'
|
||||
white='#c4c8c5'
|
||||
dark_gray='#363a41'
|
||||
red='#cc6666'
|
||||
gray='#1d1f21'
|
||||
dark_purple='#373b41'
|
||||
"
|
||||
```
|
||||
|
||||
Alternatively use the full tomorrow color palette and customise the flags accordingly
|
||||
|
||||
# Tomorrow Night Color Palette
|
||||
## Tomorrow
|
||||
```
|
||||
foreground='#4d4d4c'
|
||||
background='#ffffff'
|
||||
highlight='#d6d6d6'
|
||||
status_line='#efefef'
|
||||
comment='#8e908c'
|
||||
red='#c82829'
|
||||
orange='#f5871f'
|
||||
yellow='#eab700'
|
||||
green='#718c00'
|
||||
aqua='#3e999f'
|
||||
blue='#4271ae'
|
||||
purple='#8959a8'
|
||||
pane='#efefef'
|
||||
```
|
||||
## Tomorrow Night
|
||||
```
|
||||
foreground='#c5c8c6'
|
||||
background='#1d1f21'
|
||||
highlight='#373b41'
|
||||
status_line='#282a2e'
|
||||
comment='#969896'
|
||||
red='#cc6666'
|
||||
orange='#de935f'
|
||||
yellow='#f0c674'
|
||||
green='#b5bd68'
|
||||
aqua='#8abeb7'
|
||||
blue='#81a2be'
|
||||
purple='#b294bb'
|
||||
pane='#4d5057'
|
||||
```
|
||||
## Tomorrow Night Eighties
|
||||
```
|
||||
foreground='#4d4d4c'
|
||||
background='#ffffff'
|
||||
highlight='#d6d6d6'
|
||||
status_line='#efefef'
|
||||
comment='#8e908c'
|
||||
red='#c82829'
|
||||
orange='#f5871f'
|
||||
yellow='#eab700'
|
||||
green='#718c00'
|
||||
aqua='#3e999f'
|
||||
blue='#4271ae'
|
||||
purple='#8959a8'
|
||||
pane='#efefef'
|
||||
```
|
||||
## Tomorrow Night Bright
|
||||
```
|
||||
foreground='#eaeaea'
|
||||
background='#000000'
|
||||
highlight='#424242'
|
||||
status_line='#2a2a2a'
|
||||
comment='#969896'
|
||||
red='#d54e53'
|
||||
orange='#e78c45'
|
||||
yellow='#e7c547'
|
||||
green='#b9ca4a'
|
||||
aqua='#70c0b1'
|
||||
blue='#7aa6da'
|
||||
purple='#c397d8'
|
||||
pane='#4d5057'
|
||||
```
|
||||
## Tomorrow Night Blue
|
||||
```
|
||||
foreground='#ffffff'
|
||||
background='#002451'
|
||||
highlight='#003f8e'
|
||||
status_line='#00346e'
|
||||
comment='#7285b7'
|
||||
red='#ff9da4'
|
||||
orange='#ffc58f'
|
||||
yellow='#ffeead'
|
||||
green='#d1f1a9'
|
||||
aqua='#99ffff'
|
||||
blue='#bbdaff'
|
||||
purple='#ebbbff'
|
||||
pane='#4d5057'
|
||||
```
|
||||
|
||||
>For more information about the tomorrow theme, here is the repo made by [chriskempson](https://github.com/chriskempson/tomorrow-theme/tree/master)
|
||||
8
data/tmux/plugins/tmux/dracula.tmux
Executable file
8
data/tmux/plugins/tmux/dracula.tmux
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# source and run dracula theme
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
$current_dir/scripts/dracula.sh
|
||||
|
||||
BIN
data/tmux/plugins/tmux/screenshot.png
Normal file
BIN
data/tmux/plugins/tmux/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 410 KiB |
35
data/tmux/plugins/tmux/scripts/attached_clients.sh
Executable file
35
data/tmux/plugins/tmux/scripts/attached_clients.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# configuration
|
||||
# @dracula-clients-minimum 1
|
||||
# @dracula-clients-singular client
|
||||
# @dracula-clients-plural clients
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
count_clients() {
|
||||
pane=$(tmux list-panes -F "#{session_name}" | head -n 1)
|
||||
tmux list-clients -t $pane | wc -l | tr -d ' '
|
||||
}
|
||||
|
||||
main() {
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
clients_count=$(count_clients)
|
||||
clients_minimum=$(get_tmux_option "@dracula-clients-minimum" 1)
|
||||
if (( $clients_count >= $clients_minimum )); then
|
||||
if (( $clients_count > 1 )); then
|
||||
clients_label=$(get_tmux_option "@dracula-clients-plural" "clients")
|
||||
else
|
||||
clients_label=$(get_tmux_option "@dracula-clients-singular" "client")
|
||||
fi
|
||||
echo "$clients_count $clients_label"
|
||||
fi
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
||||
200
data/tmux/plugins/tmux/scripts/battery.sh
Executable file
200
data/tmux/plugins/tmux/scripts/battery.sh
Executable file
|
|
@ -0,0 +1,200 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
linux_acpi() {
|
||||
arg=$1
|
||||
BAT=$(ls -d /sys/class/power_supply/*)
|
||||
if [ ! -x "$(which acpi 2> /dev/null)" ];then
|
||||
for DEV in $BAT; do
|
||||
case "$arg" in
|
||||
status)
|
||||
[ -f "$DEV/status" ] && cat "$DEV/status"
|
||||
;;
|
||||
percent)
|
||||
[ -f "$DEV/capacity" ] && cat "$DEV/capacity"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
case "$arg" in
|
||||
status)
|
||||
acpi | cut -d: -f2- | cut -d, -f1 | tr -d ' '
|
||||
;;
|
||||
percent)
|
||||
acpi | cut -d: -f2- | cut -d, -f2 | tr -d '% '
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
battery_percent()
|
||||
{
|
||||
# Check OS
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
percent=$(linux_acpi percent)
|
||||
[ -n "$percent" ] && echo "$percent%"
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
echo $(pmset -g batt | grep -Eo '[0-9]?[0-9]?[0-9]%')
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
echo $(apm | sed '8,11d' | grep life | awk '{print $4}')
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# leaving empty - TODO - windows compatability
|
||||
;;
|
||||
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_battery_status()
|
||||
{
|
||||
# Check OS
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
status=$(linux_acpi status)
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
status=$(pmset -g batt | sed -n 2p | cut -d ';' -f 2 | tr -d " ")
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
status=$(apm | sed '8,11d' | grep Status | awk '{printf $3}')
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# leaving empty - TODO - windows compatability
|
||||
;;
|
||||
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
echo "$status"
|
||||
}
|
||||
|
||||
parse_battery_status()
|
||||
{
|
||||
# $1 is battery_percent
|
||||
bat_perc="$1"
|
||||
# $2 is get_battery_status
|
||||
status="$2"
|
||||
|
||||
case $status in
|
||||
discharging|Discharging)
|
||||
# discharging, no AC
|
||||
declare -A battery_labels=(
|
||||
[0]=""
|
||||
[10]=""
|
||||
[20]=""
|
||||
[30]=""
|
||||
[40]=""
|
||||
[50]=""
|
||||
[60]=""
|
||||
[70]=""
|
||||
[80]=""
|
||||
[90]=""
|
||||
[100]=""
|
||||
)
|
||||
echo "${battery_labels[$((bat_perc/10*10))]:-}"
|
||||
;;
|
||||
high|charged|Full)
|
||||
echo ""
|
||||
;;
|
||||
charging|Charging)
|
||||
# charging from AC
|
||||
declare -A battery_labels=(
|
||||
[0]=""
|
||||
[10]=""
|
||||
[20]=""
|
||||
[30]=""
|
||||
[40]=""
|
||||
[50]=""
|
||||
[60]=""
|
||||
[70]=""
|
||||
[80]=""
|
||||
[90]=""
|
||||
[100]=""
|
||||
)
|
||||
echo "${battery_labels[$((bat_perc/10*10))]:-}"
|
||||
;;
|
||||
ACattached|Notcharging|"Not charging")
|
||||
# drawing from AC but not charging
|
||||
# ACattached - MacOS
|
||||
# Not charging - Linux without acpi
|
||||
# Notcharging - Linux with acpi
|
||||
echo ''
|
||||
;;
|
||||
finishingcharge)
|
||||
echo ''
|
||||
;;
|
||||
*)
|
||||
# something wrong...
|
||||
echo ''
|
||||
;;
|
||||
esac
|
||||
### Old if statements didn't work on BSD, they're probably not POSIX compliant, not sure
|
||||
# if [ $status = 'discharging' ] || [ $status = 'Discharging' ]; then
|
||||
# echo ''
|
||||
# # elif [ $status = 'charging' ]; then # This is needed for FreeBSD AC checking support
|
||||
# # echo 'AC'
|
||||
# else
|
||||
# echo 'AC'
|
||||
# fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
# get left most custom label
|
||||
bat_label=$(get_tmux_option "@dracula-battery-label" "♥")
|
||||
if [ "$bat_label" == false ]; then
|
||||
bat_label=""
|
||||
fi
|
||||
|
||||
# get label for when there is no battery
|
||||
no_bat_label=$(get_tmux_option "@dracula-no-battery-label" "AC")
|
||||
if [ "$no_bat_label" == false ]; then
|
||||
no_bat_label=""
|
||||
fi
|
||||
|
||||
bat_perc=$(battery_percent)
|
||||
bat_perc="${bat_perc%\%}"
|
||||
|
||||
# display widget
|
||||
if [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power
|
||||
echo "$no_bat_label"
|
||||
else
|
||||
IFS=$'\n' read -rd '' -a percs <<<"$bat_perc"
|
||||
IFS=$'\n' read -rd '' -a stats <<<"$(get_battery_status)"
|
||||
IFS=$'\n' read -rd '' -a lbls <<<"$bat_label"
|
||||
num_bats=${#percs[@]}
|
||||
show_bat_label=$(get_tmux_option "@dracula-show-battery-status" false)
|
||||
for ((i=0; i<num_bats; i++)); do
|
||||
if [[ i -gt 0 ]]; then
|
||||
echo -n "$(get_tmux_option "@dracula-battery-separator" "; ")"
|
||||
fi
|
||||
echo -n "${lbls[$i]}"
|
||||
if $show_bat_label; then
|
||||
echo -n "$(parse_battery_status "${percs[$i]}" "${stats[$i]}") "
|
||||
fi
|
||||
echo -n "${percs[$i]}%"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
||||
44
data/tmux/plugins/tmux/scripts/compact_alt.sh
Executable file
44
data/tmux/plugins/tmux/scripts/compact_alt.sh
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
main()
|
||||
{
|
||||
# get options
|
||||
min_width=$(get_tmux_option "@dracula-compact-min-width" "140")
|
||||
|
||||
# get current window with
|
||||
local window_width
|
||||
window_width=$(tmux display-message -p "#{window_width}")
|
||||
|
||||
# determine whether narrow
|
||||
if [[ "$window_width" -lt "$min_width" ]]; then
|
||||
narrow=true
|
||||
else
|
||||
narrow=false
|
||||
fi
|
||||
|
||||
# get whether narrow previously
|
||||
narrow_mode="$(tmux show-option -gqv '@dracula-narrow-mode')"
|
||||
|
||||
# if width changed, set global var and reload
|
||||
if [[ "$narrow" != "$narrow_mode" ]]; then
|
||||
tmux set -g @dracula-narrow-mode $narrow
|
||||
tmux source-file "$(get_tmux_option "@dracula-config-path" "$HOME/.config/tmux/tmux.conf")"
|
||||
fi
|
||||
|
||||
# show widget info if verbose
|
||||
verbose=$(get_tmux_option "@dracula-compact-alt-verbose" false)
|
||||
if $verbose; then
|
||||
echo "$window_width - $narrow"
|
||||
fi
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
||||
161
data/tmux/plugins/tmux/scripts/continuum.sh
Executable file
161
data/tmux/plugins/tmux/scripts/continuum.sh
Executable file
|
|
@ -0,0 +1,161 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# configuration
|
||||
# @dracula-continuum-mode default (countdown|time|alert|interval)
|
||||
# @dracula-continuum-time-threshold 15
|
||||
|
||||
alert_mode="@dracula-continuum-mode"
|
||||
time_threshold="@dracula-continuum-time-threshold"
|
||||
warn_threshold=360
|
||||
first_save="@dracula-continuum-first-save"
|
||||
|
||||
# tmux-resurrect and tmux-continuum options
|
||||
if [ -d "$HOME/.tmux/resurrect" ]; then
|
||||
default_resurrect_dir="$HOME/.tmux/resurrect"
|
||||
else
|
||||
default_resurrect_dir="${XDG_DATA_HOME:-$HOME/.local/share}"/tmux/resurrect
|
||||
fi
|
||||
resurrect_dir_option="@resurrect-dir"
|
||||
last_auto_save_option="@continuum-save-last-timestamp"
|
||||
auto_save_interval_option="@continuum-save-interval"
|
||||
auto_save_interval_default="15"
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
current_timestamp() {
|
||||
echo "$(date +%s)"
|
||||
}
|
||||
|
||||
file_mtime() {
|
||||
if [ ! -f "$1" ]; then
|
||||
echo -1
|
||||
return
|
||||
fi
|
||||
case $(uname -s) in
|
||||
Linux|Darwin)
|
||||
date -r "$1" +%s
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
stat -f %m "$1"
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
timestamp_date() {
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
date -d "@$1" "$2"
|
||||
;;
|
||||
|
||||
Darwin|FreeBSD)
|
||||
date -r "$1" "$2"
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
set_tmux_option() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
tmux set-option -gq "$option" "$value"
|
||||
}
|
||||
|
||||
# tmux-resurrect dir
|
||||
resurrect_dir() {
|
||||
if [ -z "$_RESURRECT_DIR" ]; then
|
||||
local path="$(get_tmux_option "$resurrect_dir_option" "$default_resurrect_dir")"
|
||||
# expands tilde, $HOME and $HOSTNAME if used in @resurrect-dir
|
||||
echo "$path" | sed "s,\$HOME,$HOME,g; s,\$HOSTNAME,$(hostname),g; s,\~,$HOME,g"
|
||||
else
|
||||
echo "$_RESURRECT_DIR"
|
||||
fi
|
||||
}
|
||||
_RESURRECT_DIR="$(resurrect_dir)"
|
||||
|
||||
last_resurrect_file() {
|
||||
echo "$(resurrect_dir)/last"
|
||||
}
|
||||
|
||||
last_saved_timestamp() {
|
||||
local last_saved_timestamp="$(get_tmux_option "$last_auto_save_option" "")"
|
||||
local first_save_timestamp="$(get_tmux_option "$first_save" "")"
|
||||
# continuum sets the last save timestamp to the current time on first load if auto_save_option is not set
|
||||
# so we can outrace it and detect that last_uato_save_option is empty and the timestamp is a dummy save
|
||||
if [ -z "$first_save_timestamp" ]; then
|
||||
last_saved_timestamp="$(file_mtime "$(last_resurrect_file)")" || last_saved_timestamp=-1
|
||||
set_tmux_option "$first_save" "$last_saved_timestamp"
|
||||
elif [ "$first_save_timestamp" != "done" ]; then
|
||||
last_saved_timestamp="$(file_mtime "$(last_resurrect_file)")" || last_saved_timestamp=-1
|
||||
if [ "$last_saved_timestamp" -gt "$first_save_timestamp" ]; then
|
||||
set_tmux_option "$first_save" "done"
|
||||
else
|
||||
last_saved_timestamp="$first_save_timestamp"
|
||||
fi
|
||||
fi
|
||||
echo "$last_saved_timestamp"
|
||||
}
|
||||
|
||||
print_status() {
|
||||
local mode="$(get_tmux_option "$alert_mode" "countdown")"
|
||||
local info_threshold="$(get_tmux_option "$time_threshold" "15")"
|
||||
local save_int="$(get_tmux_option "$auto_save_interval_option" "$auto_save_interval_default")"
|
||||
local interval_seconds="$((save_int * 60))"
|
||||
local status=""
|
||||
local last_timestamp="$(last_saved_timestamp)"
|
||||
local time_delta="$(($(current_timestamp) - last_timestamp))"
|
||||
local time_delta_minutes="$((time_delta / 60))"
|
||||
|
||||
if [[ $save_int -gt 0 ]]; then
|
||||
if [[ "$time_delta" -gt $((interval_seconds + warn_threshold)) ]]; then
|
||||
if [[ "$last_timestamp" == -1 ]]; then
|
||||
status="no save"
|
||||
else
|
||||
status="last save: $(timestamp_date "$last_timestamp" '+%F %T')"
|
||||
fi
|
||||
if [[ "$mode" == "countdown" ]]; then
|
||||
# continuum timestamp may be different than file timestamp on first load
|
||||
local last_continuum_timestamp="$(get_tmux_option "$last_auto_save_option" "")"
|
||||
time_delta="$(($(current_timestamp) - last_continuum_timestamp))"
|
||||
time_delta_minutes="$((time_delta / 60))"
|
||||
|
||||
status="$status; T$(printf '%+d' "$((time_delta_minutes - save_int))")min"
|
||||
fi
|
||||
elif [[ "$time_delta" -le "$info_threshold" ]]; then
|
||||
status="saved"
|
||||
else
|
||||
case "$mode" in
|
||||
countdown)
|
||||
status="T$(printf '%+d' "$((time_delta_minutes - save_int))")min";
|
||||
;;
|
||||
|
||||
time)
|
||||
status="$time_delta_minutes";
|
||||
;;
|
||||
|
||||
alert)
|
||||
status=""
|
||||
;;
|
||||
|
||||
interval)
|
||||
status="$save_int"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
status="off"
|
||||
fi
|
||||
|
||||
echo "$status"
|
||||
}
|
||||
print_status
|
||||
14
data/tmux/plugins/tmux/scripts/cpu_arch.sh
Executable file
14
data/tmux/plugins/tmux/scripts/cpu_arch.sh
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
main()
|
||||
{
|
||||
cpu_label=$(get_tmux_option "@dracula-cpu-arch-label" "ARCH")
|
||||
echo "$cpu_label `uname -m`"
|
||||
}
|
||||
|
||||
main
|
||||
66
data/tmux/plugins/tmux/scripts/cpu_info.sh
Executable file
66
data/tmux/plugins/tmux/scripts/cpu_info.sh
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
get_percent()
|
||||
{
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -d 0.01 | grep "[C]pu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id, *\([0-9.]*\)%* wa.*/\1 \2/" | awk '{usage = 100 - $1 - $2; if (usage < 0.005) usage = 0; printf usage"%"}')
|
||||
normalize_percent_len $percent
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
cpuvalue=$(ps -A -o %cpu | awk -F. '{s+=$1} END {print s}')
|
||||
cpucores=$(sysctl -n hw.logicalcpu)
|
||||
cpuusage=$(( cpuvalue / cpucores ))
|
||||
percent="$cpuusage%"
|
||||
normalize_percent_len $percent
|
||||
;;
|
||||
|
||||
OpenBSD)
|
||||
cpuvalue=$(ps -A -o %cpu | awk -F. '{s+=$1} END {print s}')
|
||||
cpucores=$(sysctl -n hw.ncpuonline)
|
||||
cpuusage=$(( cpuvalue / cpucores ))
|
||||
percent="$cpuusage%"
|
||||
normalize_percent_len $percent
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_load() {
|
||||
case $(uname -s) in
|
||||
Linux | Darwin | OpenBSD)
|
||||
loadavg=$(uptime | awk -F'[a-z]:' '{ print $2}' | sed 's/,//g')
|
||||
echo $loadavg
|
||||
;;
|
||||
|
||||
CYGWIN* | MINGW32* | MSYS* | MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
cpu_load=$(get_tmux_option "@dracula-cpu-display-load" false)
|
||||
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
|
||||
if [ "$cpu_load" = true ]; then
|
||||
echo "$cpu_label $(get_load)"
|
||||
else
|
||||
cpu_percent=$(get_percent)
|
||||
echo "$cpu_label $cpu_percent"
|
||||
fi
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
||||
53
data/tmux/plugins/tmux/scripts/cwd.sh
Executable file
53
data/tmux/plugins/tmux/scripts/cwd.sh
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source "$current_dir/utils.sh"
|
||||
|
||||
# return current working directory of tmux pane
|
||||
getPaneDir() {
|
||||
nextone="false"
|
||||
ret=""
|
||||
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); do
|
||||
[ "$i" == "1" ] && nextone="true" && continue
|
||||
[ "$i" == "0" ] && nextone="false"
|
||||
[ "$nextone" == "true" ] && ret+="$i "
|
||||
done
|
||||
echo "${ret%?}"
|
||||
}
|
||||
|
||||
main() {
|
||||
path="$(getPaneDir)"
|
||||
|
||||
if [[ "$path" == "$HOME" ]]; then
|
||||
echo "~"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# change '/home/user' to '~'
|
||||
cwd="${path#"$HOME"}"
|
||||
cwd="~${cwd}"
|
||||
|
||||
# check max number of subdirs to display. 0 means unlimited
|
||||
cwd_max_dirs="$(get_tmux_option "@dracula-cwd-max-dirs" "0")"
|
||||
|
||||
if [[ "$cwd_max_dirs" -gt 0 ]]; then
|
||||
base_to_erase=$cwd
|
||||
for ((i = 0 ; i < cwd_max_dirs ; i++)); do
|
||||
base_to_erase="${base_to_erase%/*}"
|
||||
done
|
||||
# / would have #base_to_erase of 0 and ~/ has #base_to_erase of 1. we want to exclude both cases
|
||||
if [[ ${#base_to_erase} -gt 1 ]]; then
|
||||
cwd="…/${cwd:${#base_to_erase}+1}"
|
||||
fi
|
||||
fi
|
||||
|
||||
cwd_max_chars="$(get_tmux_option "@dracula-cwd-max-chars" "0")"
|
||||
if [[ "${cwd_max_chars}" -gt 0 && "${#cwd}" -gt "$cwd_max_chars" ]]; then
|
||||
cwd="…/…${cwd:(- cwd_max_chars)}"
|
||||
fi
|
||||
|
||||
echo "$cwd"
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
||||
410
data/tmux/plugins/tmux/scripts/dracula.sh
Executable file
410
data/tmux/plugins/tmux/scripts/dracula.sh
Executable file
|
|
@ -0,0 +1,410 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
main() {
|
||||
# set configuration option variables
|
||||
show_krbtgt_label=$(get_tmux_option "@dracula-krbtgt-context-label" "")
|
||||
krbtgt_principal=$(get_tmux_option "@dracula-krbtgt-principal" "")
|
||||
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
|
||||
show_only_kubernetes_context=$(get_tmux_option "@dracula-show-only-kubernetes-context" false)
|
||||
eks_hide_arn=$(get_tmux_option "@dracula-kubernetes-eks-hide-arn" false)
|
||||
eks_extract_account=$(get_tmux_option "@dracula-kubernetes-eks-extract-account" false)
|
||||
hide_kubernetes_user=$(get_tmux_option "@dracula-kubernetes-hide-user" false)
|
||||
hide_kubernetes_no_config=$(get_tmux_option "@dracula-kubernetes-hide-no-config" false)
|
||||
terraform_label=$(get_tmux_option "@dracula-terraform-label" "")
|
||||
terraform_fork=$(get_tmux_option "@dracula-terraform-fork" "terraform")
|
||||
terraform_hide_status=$(get_tmux_option "@dracula-terraform-hide" false)
|
||||
show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true)
|
||||
show_location=$(get_tmux_option "@dracula-show-location" true)
|
||||
fixed_location=$(get_tmux_option "@dracula-fixed-location")
|
||||
weather_hide_errors=$(get_tmux_option "@dracula-weather-hide-errors" false)
|
||||
show_powerline=$(get_tmux_option "@dracula-show-powerline" false)
|
||||
transparent_powerline_bg=$(get_tmux_option "@dracula-transparent-powerline-bg" false)
|
||||
show_flags=$(get_tmux_option "@dracula-show-flags" false)
|
||||
show_left_icon=$(get_tmux_option "@dracula-show-left-icon" smiley)
|
||||
show_left_icon_padding=$(get_tmux_option "@dracula-left-icon-padding" 1)
|
||||
show_military=$(get_tmux_option "@dracula-military-time" false)
|
||||
timezone=$(get_tmux_option "@dracula-set-timezone" "")
|
||||
show_timezone=$(get_tmux_option "@dracula-show-timezone" true)
|
||||
show_left_sep=$(get_tmux_option "@dracula-show-left-sep" )
|
||||
show_right_sep=$(get_tmux_option "@dracula-show-right-sep" )
|
||||
show_edge_icons=$(get_tmux_option "@dracula-show-edge-icons" false)
|
||||
show_inverse_divider=$(get_tmux_option "@dracula-inverse-divider" )
|
||||
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
|
||||
show_day_month=$(get_tmux_option "@dracula-day-month" false)
|
||||
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
show_synchronize_panes_label=$(get_tmux_option "@dracula-synchronize-panes-label" "Sync")
|
||||
time_format=$(get_tmux_option "@dracula-time-format" "")
|
||||
show_ssh_session_port=$(get_tmux_option "@dracula-show-ssh-session-port" false)
|
||||
show_libreview=$(get_tmux_option "@dracula-show-libreview" false)
|
||||
show_empty_plugins=$(get_tmux_option "@dracula-show-empty-plugins" true)
|
||||
left_pad=$(get_tmux_option "@dracula-left-pad" " ")
|
||||
right_pad=$(get_tmux_option "@dracula-right-pad" " ")
|
||||
|
||||
if [ "$left_pad" = false ]; then left_pad=""; fi
|
||||
if [ "$right_pad" = false ]; then right_pad=""; fi
|
||||
|
||||
narrow_mode=$(get_tmux_option "@dracula-narrow-mode" false)
|
||||
if $narrow_mode; then
|
||||
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-narrow-plugins" "compact-alt battery network weather")
|
||||
else
|
||||
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
|
||||
fi
|
||||
|
||||
# Dracula Color Pallette
|
||||
white="#f8f8f2"
|
||||
gray="#44475a"
|
||||
dark_gray="#282a36"
|
||||
light_purple="#bd93f9"
|
||||
dark_purple="#6272a4"
|
||||
cyan="#8be9fd"
|
||||
green="#50fa7b"
|
||||
orange="#ffb86c"
|
||||
red="#ff5555"
|
||||
purple="#b166cc"
|
||||
pink="#ff79c6"
|
||||
yellow="#f1fa8c"
|
||||
|
||||
# Override default colors and possibly add more
|
||||
colors="$(get_tmux_option "@dracula-colors" "")"
|
||||
if [ -n "$colors" ]; then
|
||||
eval "$colors"
|
||||
fi
|
||||
|
||||
# Set transparency variables - Colors and window dividers
|
||||
if $transparent_powerline_bg; then
|
||||
bg_color="default"
|
||||
if $show_edge_icons; then
|
||||
window_sep_fg=${dark_purple}
|
||||
window_sep_bg=default
|
||||
window_sep="$show_right_sep"
|
||||
else
|
||||
window_sep_fg=${dark_purple}
|
||||
window_sep_bg=default
|
||||
window_sep="$show_inverse_divider"
|
||||
fi
|
||||
else
|
||||
bg_color=${gray}
|
||||
if $show_edge_icons; then
|
||||
window_sep_fg=${dark_purple}
|
||||
window_sep_bg=${gray}
|
||||
window_sep="$show_inverse_divider"
|
||||
else
|
||||
window_sep_fg=${gray}
|
||||
window_sep_bg=${dark_purple}
|
||||
window_sep="$show_left_sep"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Handle left icon configuration
|
||||
case $show_left_icon in
|
||||
smiley)
|
||||
left_icon="☺";;
|
||||
session)
|
||||
left_icon="#S";;
|
||||
window)
|
||||
left_icon="#W";;
|
||||
hostname)
|
||||
left_icon="#H";;
|
||||
shortname)
|
||||
left_icon="#h";;
|
||||
*)
|
||||
left_icon=$show_left_icon;;
|
||||
esac
|
||||
|
||||
# Handle left icon padding
|
||||
padding=""
|
||||
if [ "$show_left_icon_padding" -gt "0" ]; then
|
||||
padding="$(printf '%*s' $show_left_icon_padding)"
|
||||
fi
|
||||
left_icon="$left_icon$padding"
|
||||
|
||||
# Handle powerline option
|
||||
if $show_powerline; then
|
||||
right_sep="$show_right_sep"
|
||||
left_sep="$show_left_sep"
|
||||
fi
|
||||
|
||||
# Set timezone unless hidden by configuration
|
||||
if [[ -z "$timezone" ]]; then
|
||||
case $show_timezone in
|
||||
false)
|
||||
timezone="";;
|
||||
true)
|
||||
timezone="#(date +%Z)";;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $show_flags in
|
||||
false)
|
||||
flags=""
|
||||
current_flags="";;
|
||||
true)
|
||||
flags="#{?window_flags,#[fg=${dark_purple}]#{window_flags},}"
|
||||
current_flags="#{?window_flags,#[fg=${light_purple}]#{window_flags},}"
|
||||
esac
|
||||
|
||||
# sets refresh interval to every 5 seconds
|
||||
tmux set-option -g status-interval $show_refresh
|
||||
|
||||
# set the prefix + t time format
|
||||
if $show_military; then
|
||||
tmux set-option -g clock-mode-style 24
|
||||
else
|
||||
tmux set-option -g clock-mode-style 12
|
||||
fi
|
||||
|
||||
# set length
|
||||
tmux set-option -g status-left-length 100
|
||||
tmux set-option -g status-right-length 100
|
||||
|
||||
# pane border styling
|
||||
if $show_border_contrast; then
|
||||
tmux set-option -g pane-active-border-style "fg=${light_purple}"
|
||||
else
|
||||
tmux set-option -g pane-active-border-style "fg=${dark_purple}"
|
||||
fi
|
||||
tmux set-option -g pane-border-style "fg=${gray}"
|
||||
|
||||
# message styling
|
||||
tmux set-option -g message-style "bg=${gray},fg=${white},fill=${gray}"
|
||||
|
||||
# status bar
|
||||
tmux set-option -g status-style "bg=${bg_color},fg=${white}"
|
||||
|
||||
# Status left
|
||||
if $show_powerline; then
|
||||
if $show_edge_icons; then
|
||||
tmux set-option -g status-left "#[bg=${bg_color}]#[fg=${green}]#[bold]#{?client_prefix,#[fg=${yellow}],}${show_right_sep}#[bg=${green}]#[fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon} #[fg=${green}]#[bg=${bg_color}]#{?client_prefix,#[fg=${yellow}],}${left_sep} "
|
||||
else
|
||||
tmux set-option -g status-left "#[bg=${dark_gray}]#[fg=${green}]#[bg=${green}]#[fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon} #[fg=${green}]#[bg=${bg_color}]#{?client_prefix,#[fg=${yellow}],}${left_sep}"
|
||||
fi
|
||||
powerbg=${bg_color}
|
||||
else
|
||||
tmux set-option -g status-left "#[bg=${green}]#[fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon}"
|
||||
fi
|
||||
|
||||
# Status right
|
||||
tmux set-option -g status-right ""
|
||||
|
||||
for plugin in "${plugins[@]}"; do
|
||||
|
||||
if case $plugin in custom:*) true;; *) false;; esac; then
|
||||
script=${plugin#"custom:"}
|
||||
if [[ -x "${current_dir}/${script}" ]]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-custom-plugin-colors" "cyan dark_gray")
|
||||
script="#($current_dir/${script})"
|
||||
else
|
||||
colors[0]="red"
|
||||
colors[1]="dark_gray"
|
||||
script="${script} not found!"
|
||||
fi
|
||||
|
||||
elif [ $plugin = "compact-alt" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-compact-alt-colors" "dark_gray white")
|
||||
tmux set-option -g status-right-length 250
|
||||
script="#($current_dir/compact_alt.sh)"
|
||||
|
||||
elif [ $plugin = "cwd" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cwd-colors" "dark_gray white")
|
||||
tmux set-option -g status-right-length 250
|
||||
script="#($current_dir/cwd.sh)"
|
||||
|
||||
elif [ $plugin = "fossil" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-fossil-colors" "green dark_gray")
|
||||
tmux set-option -g status-right-length 250
|
||||
script="#($current_dir/fossil.sh)"
|
||||
|
||||
elif [ $plugin = "git" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray")
|
||||
tmux set-option -g status-right-length 250
|
||||
script="#($current_dir/git.sh)"
|
||||
|
||||
elif [ $plugin = "hg" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-hg-colors" "green dark_gray")
|
||||
tmux set-option -g status-right-length 250
|
||||
script="#($current_dir/hg.sh)"
|
||||
|
||||
elif [ $plugin = "battery" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-battery-colors" "pink dark_gray")
|
||||
script="#($current_dir/battery.sh)"
|
||||
|
||||
elif [ $plugin = "gpu-usage" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-usage-colors" "pink dark_gray")
|
||||
script="#($current_dir/gpu_usage.sh)"
|
||||
|
||||
elif [ $plugin = "gpu-ram-usage" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-ram-usage-colors" "cyan dark_gray")
|
||||
script="#($current_dir/gpu_ram_info.sh)"
|
||||
|
||||
elif [ $plugin = "gpu-power-draw" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-power-draw-colors" "green dark_gray")
|
||||
script="#($current_dir/gpu_power.sh)"
|
||||
|
||||
elif [ $plugin = "cpu-usage" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cpu-usage-colors" "orange dark_gray")
|
||||
script="#($current_dir/cpu_info.sh)"
|
||||
|
||||
elif [ $plugin = "ram-usage" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-ram-usage-colors" "cyan dark_gray")
|
||||
script="#($current_dir/ram_info.sh)"
|
||||
|
||||
elif [ $plugin = "tmux-ram-usage" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-tmux-ram-usage-colors" "cyan dark_gray")
|
||||
script="#($current_dir/tmux_ram_info.sh)"
|
||||
|
||||
elif [ $plugin = "network" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-network-colors" "cyan dark_gray")
|
||||
script="#($current_dir/network.sh)"
|
||||
|
||||
elif [ $plugin = "network-bandwidth" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-network-bandwidth-colors" "cyan dark_gray")
|
||||
tmux set-option -g status-right-length 250
|
||||
script="#($current_dir/network_bandwidth.sh)"
|
||||
|
||||
elif [ $plugin = "network-ping" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-ping-colors" "cyan dark_gray")
|
||||
script="#($current_dir/network_ping.sh)"
|
||||
|
||||
elif [ $plugin = "network-vpn" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-vpn-colors" "cyan dark_gray")
|
||||
script="#($current_dir/network_vpn.sh)"
|
||||
|
||||
elif [ $plugin = "attached-clients" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-attached-clients-colors" "cyan dark_gray")
|
||||
script="#($current_dir/attached_clients.sh)"
|
||||
|
||||
|
||||
elif [ $plugin = "mac-player" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-mac-player-colors" "purple dark_gray")
|
||||
script="#($current_dir/mac-player.sh)"
|
||||
|
||||
elif [ $plugin = "mpc" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-mpc-colors" "green dark_gray")
|
||||
script="#($current_dir/mpc.sh)"
|
||||
|
||||
elif [ $plugin = "spr" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spr-colors" "green dark_gray")
|
||||
script="#($current_dir/spr.sh)"
|
||||
|
||||
elif [ $plugin = "spotify-tui" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray")
|
||||
script="#($current_dir/spotify-tui.sh)"
|
||||
|
||||
elif [ $plugin = "krbtgt" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-krbtgt-colors" "cyan dark_gray")
|
||||
script="#($current_dir/krbtgt.sh $krbtgt_principal $show_krbtgt_label)"
|
||||
|
||||
elif [ $plugin = "playerctl" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-playerctl-colors" "green dark_gray")
|
||||
script="#($current_dir/playerctl.sh)"
|
||||
|
||||
elif [ $plugin = "kubernetes-context" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
|
||||
script="#($current_dir/kubernetes_context.sh $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_only_kubernetes_context $hide_kubernetes_no_config $show_kubernetes_context_label)"
|
||||
|
||||
elif [ $plugin = "terraform" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
|
||||
script="#($current_dir/terraform.sh $terraform_fork $terraform_hide_status $terraform_label)"
|
||||
|
||||
elif [ $plugin = "continuum" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-continuum-colors" "cyan dark_gray")
|
||||
script="#($current_dir/continuum.sh)"
|
||||
|
||||
elif [ $plugin = "weather" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray")
|
||||
script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location '$fixed_location' $weather_hide_errors)"
|
||||
|
||||
elif [ $plugin = "time" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white")
|
||||
if [ -n "$time_format" ]; then
|
||||
script=${time_format}
|
||||
else
|
||||
if $show_day_month && $show_military ; then # military time and dd/mm
|
||||
script="%a %d/%m %R ${timezone} "
|
||||
elif $show_military; then # only military time
|
||||
script="%R ${timezone} "
|
||||
elif $show_day_month; then # only dd/mm
|
||||
script="%a %d/%m %I:%M %p ${timezone} "
|
||||
else
|
||||
script="%a %m/%d %I:%M %p ${timezone} "
|
||||
fi
|
||||
fi
|
||||
elif [ $plugin = "synchronize-panes" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-synchronize-panes-colors" "cyan dark_gray")
|
||||
script="#($current_dir/synchronize_panes.sh $show_synchronize_panes_label)"
|
||||
|
||||
elif [ $plugin = "libreview" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-libre-colors" "white dark_gray")
|
||||
script="#($current_dir/libre.sh $show_libreview)"
|
||||
|
||||
elif [ $plugin = "ssh-session" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-ssh-session-colors" "green dark_gray")
|
||||
script="#($current_dir/ssh_session.sh $show_ssh_session_port)"
|
||||
|
||||
elif [ $plugin = "network-public-ip" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-public-ip-colors" "cyan dark_gray")
|
||||
script="#($current_dir/network-public-ip.sh)"
|
||||
|
||||
elif [ $plugin = "sys-temp" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-sys-temp-colors" "green dark_gray")
|
||||
script="#($current_dir/sys_temp.sh)"
|
||||
|
||||
elif [ $plugin = "cpu-arch" ]; then
|
||||
IFS=$' ' read -r -a colors <<< $(get_tmux_option "@dracula-cpu-arch-colors" "default default")
|
||||
script="#($current_dir/cpu_arch.sh)"
|
||||
|
||||
elif [ $plugin = "uptime" ]; then
|
||||
IFS=$' ' read -r -a colors <<< $(get_tmux_option "@dracula-uptime-colors" "default default")
|
||||
script="#($current_dir/uptime.sh)"
|
||||
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
# edge styling
|
||||
if $show_edge_icons; then
|
||||
right_edge_icon="#[bg=${bg_color}]#[fg=${!colors[0]}]${show_left_sep}"
|
||||
background_color=${bg_color}
|
||||
else
|
||||
background_color=${powerbg}
|
||||
fi
|
||||
|
||||
# padding
|
||||
pad_script="$left_pad$script$right_pad"
|
||||
|
||||
if $show_powerline; then
|
||||
if $show_empty_plugins; then
|
||||
tmux set-option -ga status-right " #[fg=${!colors[0]}]#[bg=${background_color}]#[nobold]#[nounderscore]#[noitalics]${right_sep}#[fg=${!colors[1]}]#[bg=${!colors[0]}]$pad_script$right_edge_icon"
|
||||
else
|
||||
tmux set-option -ga status-right "#{?#{==:$script,},,#[fg=${!colors[0]}]#[nobold]#[nounderscore]#[noitalics]${right_sep}#[fg=${!colors[1]}]#[bg=${!colors[0]}]$pad_script$right_edge_icon}"
|
||||
fi
|
||||
powerbg=${!colors[0]}
|
||||
else
|
||||
if $show_empty_plugins; then
|
||||
tmux set-option -ga status-right "#[fg=${!colors[1]}]#[bg=${!colors[0]}]$pad_script"
|
||||
else
|
||||
tmux set-option -ga status-right "#{?#{==:$script,},,#[fg=${!colors[1]}]#[bg=${!colors[0]}]$pad_script}"
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Window option
|
||||
if $show_powerline; then
|
||||
tmux set-window-option -g window-status-current-format "#[fg=${window_sep_fg}]#[bg=${window_sep_bg}]${window_sep}#[fg=${white}]#[bg=${dark_purple}] #I #W${current_flags} #[fg=${dark_purple}]#[bg=${bg_color}]${left_sep}"
|
||||
else
|
||||
tmux set-window-option -g window-status-current-format "#[fg=${white}]#[bg=${dark_purple}] #I #W${current_flags} "
|
||||
fi
|
||||
|
||||
tmux set-window-option -g window-status-format "#[fg=${white}]#[bg=${bg_color}] #I #W${flags}"
|
||||
tmux set-window-option -g window-status-activity-style "bold"
|
||||
tmux set-window-option -g window-status-bell-style "bold"
|
||||
}
|
||||
|
||||
# run main function
|
||||
main
|
||||
178
data/tmux/plugins/tmux/scripts/fossil.sh
Executable file
178
data/tmux/plugins/tmux/scripts/fossil.sh
Executable file
|
|
@ -0,0 +1,178 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
IFS=' ' read -r -a hide_status <<< $(get_tmux_option "@dracula-fossil-disable-status" "false")
|
||||
IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-fossil-show-current-symbol" "✓")
|
||||
IFS=' ' read -r -a diff_symbol <<< $(get_tmux_option "@dracula-fossil-show-diff-symbol" "!")
|
||||
IFS=' ' read -r -a no_repo_message <<< $(get_tmux_option "@dracula-fossil-no-repo-message" "")
|
||||
IFS=' ' read -r -a no_untracked_files <<< $(get_tmux_option "@dracula-fossil-no-untracked-files" "false")
|
||||
IFS=' ' read -r -a show_remote_status <<< $(get_tmux_option "@dracula-fossil-show-remote-status" "false")
|
||||
|
||||
# Get added, modified, updated and deleted files from git status
|
||||
getChanges()
|
||||
{
|
||||
declare -i added=0;
|
||||
declare -i modified=0;
|
||||
declare -i updated=0;
|
||||
declare -i deleted=0;
|
||||
|
||||
for i in $(cd $path; fossil changes --differ|cut -f1 -d' ')
|
||||
|
||||
do
|
||||
case $i in
|
||||
'EXTRA')
|
||||
added+=1
|
||||
;;
|
||||
'EDITED')
|
||||
modified+=1
|
||||
;;
|
||||
'U')
|
||||
updated+=1
|
||||
;;
|
||||
'DELETED')
|
||||
deleted+=1
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
output=""
|
||||
[ $added -gt 0 ] && output+="${added}A"
|
||||
[ $modified -gt 0 ] && output+=" ${modified}M"
|
||||
[ $updated -gt 0 ] && output+=" ${updated}U"
|
||||
[ $deleted -gt 0 ] && output+=" ${deleted}D"
|
||||
|
||||
echo $output
|
||||
}
|
||||
|
||||
|
||||
# getting the #{pane_current_path} from dracula.sh is no longer possible
|
||||
getPaneDir()
|
||||
{
|
||||
nextone="false"
|
||||
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}");
|
||||
do
|
||||
if [ "$nextone" == "true" ]; then
|
||||
echo $i
|
||||
return
|
||||
fi
|
||||
if [ "$i" == "1" ]; then
|
||||
nextone="true"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# check if the current or diff symbol is empty to remove ugly padding
|
||||
checkEmptySymbol()
|
||||
{
|
||||
symbol=$1
|
||||
if [ "$symbol" == "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# check to see if the current repo is not up to date with HEAD
|
||||
checkForChanges()
|
||||
{
|
||||
if [ "$(checkForFossilDir)" == "true" ]; then
|
||||
if [ "$(cd $path; fossil changes --differ)" != "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# check if a git repo exists in the directory
|
||||
checkForFossilDir()
|
||||
{
|
||||
if [ -f ${path}/.fslckout ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# return branch name if there is one
|
||||
getBranch()
|
||||
{
|
||||
if [ $(checkForFossilDir) == "true" ]; then
|
||||
echo $(cd $path; fossil branch current)
|
||||
else
|
||||
echo $no_repo_message
|
||||
fi
|
||||
}
|
||||
|
||||
getRemoteInfo()
|
||||
{
|
||||
base=$(cd $path; fossil branch current)
|
||||
remote=$(echo "$base" | cut -d" " -f1)
|
||||
out=""
|
||||
|
||||
if [ -n "$remote" ]; then
|
||||
out="...$remote"
|
||||
ahead=$(echo "$base" | grep -E -o 'ahead[ [:digit:]]+' | cut -d" " -f2)
|
||||
behind=$(echo "$base" | grep -E -o 'behind[ [:digit:]]+' | cut -d" " -f2)
|
||||
|
||||
[ -n "$ahead" ] && out+=" +$ahead"
|
||||
[ -n "$behind" ] && out+=" -$behind"
|
||||
fi
|
||||
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
# return the final message for the status bar
|
||||
getMessage()
|
||||
{
|
||||
if [ $(checkForFossilDir) == "true" ]; then
|
||||
branch="$(getBranch)"
|
||||
output=""
|
||||
|
||||
if [ $(checkForChanges) == "true" ]; then
|
||||
|
||||
changes="$(getChanges)"
|
||||
|
||||
if [ "${hide_status}" == "false" ]; then
|
||||
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
|
||||
output=$(echo "${changes} $branch")
|
||||
else
|
||||
output=$(echo "$diff_symbol ${changes} $branch")
|
||||
fi
|
||||
else
|
||||
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
|
||||
output=$(echo "$branch")
|
||||
else
|
||||
output=$(echo "$diff_symbol $branch")
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
|
||||
output=$(echo "$branch")
|
||||
else
|
||||
output=$(echo "$current_symbol $branch")
|
||||
fi
|
||||
fi
|
||||
|
||||
[ "$show_remote_status" == "true" ] && output+=$(getRemoteInfo)
|
||||
echo "$output"
|
||||
else
|
||||
echo $no_repo_message
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
path=$(getPaneDir)
|
||||
getMessage
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
||||
191
data/tmux/plugins/tmux/scripts/git.sh
Executable file
191
data/tmux/plugins/tmux/scripts/git.sh
Executable file
|
|
@ -0,0 +1,191 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
IFS=' ' read -r -a hide_status <<< $(get_tmux_option "@dracula-git-disable-status" "false")
|
||||
IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-git-show-current-symbol" "✓")
|
||||
IFS=' ' read -r -a diff_symbol <<< $(get_tmux_option "@dracula-git-show-diff-symbol" "!")
|
||||
IFS=' ' read -r -a no_repo_message <<< $(get_tmux_option "@dracula-git-no-repo-message" "")
|
||||
IFS=' ' read -r -a no_untracked_files <<< $(get_tmux_option "@dracula-git-no-untracked-files" "false")
|
||||
IFS=' ' read -r -a show_remote_status <<< $(get_tmux_option "@dracula-git-show-remote-status" "false")
|
||||
show_repo_name="$(get_tmux_option "@dracula-git-show-repo-name" "false")"
|
||||
git_truncate_length="$(get_tmux_option "@dracula-git-truncate-length" "")"
|
||||
|
||||
# Get added, modified, updated and deleted files from git status
|
||||
getChanges()
|
||||
{
|
||||
declare -i added=0;
|
||||
declare -i modified=0;
|
||||
declare -i updated=0;
|
||||
declare -i deleted=0;
|
||||
|
||||
for i in $(git -C $path --no-optional-locks status -s)
|
||||
|
||||
do
|
||||
case $i in
|
||||
'A')
|
||||
added+=1
|
||||
;;
|
||||
'M')
|
||||
modified+=1
|
||||
;;
|
||||
'U')
|
||||
updated+=1
|
||||
;;
|
||||
'D')
|
||||
deleted+=1
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
output=""
|
||||
[ $added -gt 0 ] && output+="${added}A"
|
||||
[ $modified -gt 0 ] && output+=" ${modified}M"
|
||||
[ $updated -gt 0 ] && output+=" ${updated}U"
|
||||
[ $deleted -gt 0 ] && output+=" ${deleted}D"
|
||||
|
||||
echo $output
|
||||
}
|
||||
|
||||
|
||||
# getting the #{pane_current_path} from dracula.sh is no longer possible
|
||||
getPaneDir()
|
||||
{
|
||||
nextone="false"
|
||||
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}");
|
||||
do
|
||||
if [ "$nextone" == "true" ]; then
|
||||
echo $i
|
||||
return
|
||||
fi
|
||||
if [ "$i" == "1" ]; then
|
||||
nextone="true"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# check if the current or diff symbol is empty to remove ugly padding
|
||||
checkEmptySymbol()
|
||||
{
|
||||
symbol=$1
|
||||
if [ "$symbol" == "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# check to see if the current repo is not up to date with HEAD
|
||||
checkForChanges()
|
||||
{
|
||||
[ $no_untracked_files == "false" ] && no_untracked="" || no_untracked="-uno"
|
||||
if [ "$(checkForGitDir)" == "true" ]; then
|
||||
if [ "$(git -C $path --no-optional-locks status -s $no_untracked)" != "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# check if a git repo exists in the directory
|
||||
checkForGitDir()
|
||||
{
|
||||
if [ "$(git -C $path rev-parse --abbrev-ref HEAD)" != "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# return branch name if there is one
|
||||
getBranch()
|
||||
{
|
||||
if [ $(checkForGitDir) == "true" ]; then
|
||||
echo $(git -C $path rev-parse --abbrev-ref HEAD)
|
||||
else
|
||||
echo $no_repo_message
|
||||
fi
|
||||
}
|
||||
|
||||
getRemoteInfo()
|
||||
{
|
||||
base=$(git -C $path for-each-ref --format='%(upstream:short) %(upstream:track)' "$(git -C $path symbolic-ref -q HEAD)")
|
||||
remote=$(echo "$base" | cut -d" " -f1)
|
||||
out=""
|
||||
|
||||
if [ -n "$remote" ]; then
|
||||
out="...$remote"
|
||||
ahead=$(echo "$base" | grep -E -o 'ahead[ [:digit:]]+' | cut -d" " -f2)
|
||||
behind=$(echo "$base" | grep -E -o 'behind[ [:digit:]]+' | cut -d" " -f2)
|
||||
|
||||
[ -n "$ahead" ] && out+=" +$ahead"
|
||||
[ -n "$behind" ] && out+=" -$behind"
|
||||
fi
|
||||
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
getRepoName()
|
||||
{
|
||||
if [ "$show_repo_name" = "true" ] && [ "$(checkForGitDir)" = "true" ]; then
|
||||
repo="$(basename "$(git -C "$path" --no-optional-locks rev-parse --show-toplevel 2>/dev/null)")"
|
||||
echo "$repo | "
|
||||
fi
|
||||
}
|
||||
|
||||
# return the final message for the status bar
|
||||
getMessage()
|
||||
{
|
||||
if [ $(checkForGitDir) == "true" ]; then
|
||||
branch="$(getBranch)"
|
||||
[ -n "$git_truncate_length" ] && branch="${branch:0:$git_truncate_length}"
|
||||
repo_name="$(getRepoName)"
|
||||
output=""
|
||||
|
||||
if [ $(checkForChanges) == "true" ]; then
|
||||
|
||||
changes="$(getChanges)"
|
||||
|
||||
if [ "${hide_status}" == "false" ]; then
|
||||
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
|
||||
output="$repo_name${changes:+ ${changes}} $branch"
|
||||
else
|
||||
output="$repo_name${diff_symbol[0]} ${changes:+$changes }$branch"
|
||||
fi
|
||||
else
|
||||
if [ "$(checkEmptySymbol "${diff_symbol[0]}")" = "true" ]; then
|
||||
output=$(echo "$repo_name$branch")
|
||||
else
|
||||
output=$(echo "$repo_name$diff_symbol $branch")
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
|
||||
output=$(echo "$repo_name$branch")
|
||||
else
|
||||
output="$repo_name${current_symbol[0]} $branch"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ "$show_remote_status" == "true" ] && output+=$(getRemoteInfo)
|
||||
echo "$output"
|
||||
else
|
||||
echo $no_repo_message
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
path=$(getPaneDir)
|
||||
getMessage
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
||||
79
data/tmux/plugins/tmux/scripts/gpu_power.sh
Executable file
79
data/tmux/plugins/tmux/scripts/gpu_power.sh
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
get_platform()
|
||||
{
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
# use this option for when your gpu isn't detected
|
||||
gpu_label=$(get_tmux_option "@dracula-force-gpu" false)
|
||||
if [[ "$gpu_label" != false ]]; then
|
||||
echo $gpu_label
|
||||
else
|
||||
# attempt to detect the gpu
|
||||
gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}')
|
||||
if [[ -n $gpu ]]; then
|
||||
# if a gpu is detected, return it
|
||||
echo $gpu
|
||||
elif type -a nvidia-smi >> /dev/null; then
|
||||
# if no gpu was detected, and nvidia-smi is installed, we'll still try nvidia
|
||||
echo "NVIDIA"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
# WARNING: for this to work the powermetrics command needs to be run without password
|
||||
# add this to the sudoers file, replacing the username and omitting the quotes.
|
||||
# be mindful of the tabs: "username ALL = (root) NOPASSWD: /usr/bin/powermetrics"
|
||||
echo "apple"
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
get_gpu()
|
||||
{
|
||||
gpu=$(get_platform)
|
||||
gpu_power_percent=$(get_tmux_option "@dracula-gpu-power-percent" false)
|
||||
if [[ "$gpu" == NVIDIA ]]; then
|
||||
if $gpu_power_percent; then
|
||||
usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,noheader,nounits | awk -F ', *' '{ printf("|%d%%", $0 / $2 * 100) }' && echo "|")
|
||||
else
|
||||
usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,noheader,nounits | awk -F ', *' '{ printf("|%dW/%dW", $0, $2) }' && echo "|")
|
||||
fi
|
||||
|
||||
elif [[ "$gpu" == apple ]]; then
|
||||
usage="$(sudo powermetrics --samplers gpu_power -i500 -n 1 | grep 'GPU Power' | sed 's/GPU Power: \(.*\) \(.*\)/\1\2/g')"
|
||||
elif [[ "$gpu" == Advanced ]]; then
|
||||
usage=$(
|
||||
for card in /sys/class/drm/card?
|
||||
do
|
||||
echo "$(($(cat "$card"/device/hwmon/hwmon?/power1_average) / 1000 / 1000))/$(($(cat "$card"/device/hwmon/hwmon?/power1_cap_max) / 1000 / 1000))W"
|
||||
done | \
|
||||
sed -z -e 's/\n/|/g' -e 's/|$//g'
|
||||
)
|
||||
else # "Intel" "Matrox", etc
|
||||
usage="unknown"
|
||||
fi
|
||||
echo $usage
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
gpu_label=$(get_tmux_option "@dracula-gpu-power-label" "GPU")
|
||||
gpu_usage=$(get_gpu)
|
||||
echo "$gpu_label $gpu_usage"
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
79
data/tmux/plugins/tmux/scripts/gpu_ram_info.sh
Executable file
79
data/tmux/plugins/tmux/scripts/gpu_ram_info.sh
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
get_platform()
|
||||
{
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
# use this option for when your gpu isn't detected
|
||||
gpu_label=$(get_tmux_option "@dracula-force-gpu" false)
|
||||
if [[ "$gpu_label" != false ]]; then
|
||||
echo $gpu_label
|
||||
else
|
||||
# attempt to detect the gpu
|
||||
gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}')
|
||||
if [[ -n $gpu ]]; then
|
||||
# if a gpu is detected, return it
|
||||
echo $gpu
|
||||
elif type -a nvidia-smi >> /dev/null; then
|
||||
# if no gpu was detected, and nvidia-smi is installed, we'll still try nvidia
|
||||
echo "NVIDIA"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
# TODO - Darwin/Mac compatability
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_gpu()
|
||||
{
|
||||
gpu=$(get_platform)
|
||||
gpu_vram_percent=$(get_tmux_option "@dracula-gpu-vram-percent" false)
|
||||
if [[ "$gpu" == NVIDIA ]]; then
|
||||
if $gpu_vram_percent; then
|
||||
usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk -F ', *' '{ printf("|%d%%", $0 / $2 * 100) }' && echo "|")
|
||||
echo $usage
|
||||
exit 0
|
||||
else
|
||||
used_accuracy=$(get_tmux_option "@dracula-gpu-vram-used-accuracy" "d")
|
||||
total_accuracy=$(get_tmux_option "@dracula-gpu-vram-total-accuracy" "d")
|
||||
usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk -F ", *" "{ printf(\"|%${used_accuracy}GB/%${total_accuracy}GB\", \$0 / 1024, \$2 / 1024) }" && echo "|")
|
||||
fi
|
||||
elif [[ "$gpu" == Advanced ]]; then
|
||||
usage="$(
|
||||
for card in /sys/class/drm/card?
|
||||
do
|
||||
use=$(cat "$card"/device/mem_info_vram_used | numfmt --to=iec --suffix=B)
|
||||
max=$(cat "$card"/device/mem_info_vram_total | numfmt --to=iec --suffix=B)
|
||||
echo "$use/$max"
|
||||
done | sed -z -e 's/\n/|/g' -e 's/|$//g'
|
||||
)"
|
||||
else # "Intel" "Matrox", etc
|
||||
usage="unknown"
|
||||
fi
|
||||
echo $usage
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
gpu_label=$(get_tmux_option "@dracula-gpu-vram-label" "VRAM")
|
||||
gpu_usage=$(get_gpu)
|
||||
echo "$gpu_label $gpu_usage"
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
68
data/tmux/plugins/tmux/scripts/gpu_usage.sh
Executable file
68
data/tmux/plugins/tmux/scripts/gpu_usage.sh
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
get_platform()
|
||||
{
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
# use this option for when your gpu isn't detected
|
||||
gpu_label=$(get_tmux_option "@dracula-force-gpu" false)
|
||||
if [[ "$gpu_label" != false ]]; then
|
||||
echo $gpu_label
|
||||
else
|
||||
# attempt to detect the gpu
|
||||
gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}')
|
||||
if [[ -n $gpu ]]; then
|
||||
# if a gpu is detected, return it
|
||||
echo $gpu
|
||||
elif type -a nvidia-smi >> /dev/null; then
|
||||
# if no gpu was detected, and nvidia-smi is installed, we'll still try nvidia
|
||||
echo "NVIDIA"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
# WARNING: for this to work the powermetrics command needs to be run without password
|
||||
# add this to the sudoers file, replacing the username and omitting the quotes.
|
||||
# be mindful of the tabs: "username ALL = (root) NOPASSWD: /usr/bin/powermetrics"
|
||||
echo "apple"
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_gpu()
|
||||
{
|
||||
gpu=$(get_platform)
|
||||
if [[ "$gpu" == NVIDIA ]]; then
|
||||
usage=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | awk -F ', *' '{ printf("|%d%%", $1) }' && echo "|")
|
||||
elif [[ "$gpu" == apple ]]; then
|
||||
usage="$(sudo powermetrics --samplers gpu_power -i500 -n 1 | grep 'active residency' | sed 's/[^0-9.%]//g' | sed 's/[%].*$//g')%"
|
||||
elif [[ "$gpu" == Advanced ]]; then
|
||||
usage="$(cat /sys/class/drm/card?/device/gpu_busy_percent | sed -z -e 's/\n/%|/g' -e 's/|$//g')"
|
||||
else # "Intel" "Matrox", etc
|
||||
usage="unknown"
|
||||
fi
|
||||
echo $usage
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "GPU")
|
||||
gpu_usage=$(get_gpu)
|
||||
echo "$gpu_label $gpu_usage"
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
163
data/tmux/plugins/tmux/scripts/hg.sh
Executable file
163
data/tmux/plugins/tmux/scripts/hg.sh
Executable file
|
|
@ -0,0 +1,163 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
IFS=' ' read -r -a hide_status <<< $(get_tmux_option "@dracula-hg-disable-status" "false")
|
||||
IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-hg-show-current-symbol" "✓")
|
||||
IFS=' ' read -r -a diff_symbol <<< $(get_tmux_option "@dracula-hg-show-diff-symbol" "!")
|
||||
IFS=' ' read -r -a no_repo_message <<< $(get_tmux_option "@dracula-hg-no-repo-message" "")
|
||||
IFS=' ' read -r -a no_untracked_files <<< $(get_tmux_option "@dracula-hg-no-untracked-files" "false")
|
||||
|
||||
# Get added, modified, and removed files from hg status
|
||||
getChanges()
|
||||
{
|
||||
declare -i added=0;
|
||||
declare -i deleted=0;
|
||||
declare -i modified=0;
|
||||
declare -i removed=0;
|
||||
declare -i untracked=0;
|
||||
|
||||
for i in $(hg -R $path status -admru)
|
||||
do
|
||||
case $i in
|
||||
'A')
|
||||
added+=1
|
||||
;;
|
||||
'!')
|
||||
deleted+=1
|
||||
;;
|
||||
'M')
|
||||
modified+=1
|
||||
;;
|
||||
'R')
|
||||
removed+=1
|
||||
;;
|
||||
'?')
|
||||
untracked+=1
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
output=""
|
||||
[ $added -gt 0 ] && output+="${added}A"
|
||||
[ $modified -gt 0 ] && output+=" ${modified}M"
|
||||
[ $deleted -gt 0 ] && output+=" ${deleted}D"
|
||||
[ $removed -gt 0 ] && output+=" ${removed}R"
|
||||
[ $no_untracked_files == "false" -a $untracked -gt 0 ] && output+=" ${untracked}?"
|
||||
|
||||
echo $output
|
||||
}
|
||||
|
||||
|
||||
# getting the #{pane_current_path} from dracula.sh is no longer possible
|
||||
getPaneDir()
|
||||
{
|
||||
nextone="false"
|
||||
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}");
|
||||
do
|
||||
if [ "$nextone" == "true" ]; then
|
||||
echo $i
|
||||
return
|
||||
fi
|
||||
if [ "$i" == "1" ]; then
|
||||
nextone="true"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# check if the current or diff symbol is empty to remove ugly padding
|
||||
checkEmptySymbol()
|
||||
{
|
||||
symbol=$1
|
||||
if [ "$symbol" == "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# check to see if the current repo is not up to date with HEAD
|
||||
checkForChanges()
|
||||
{
|
||||
[ $no_untracked_files == "false" ] && no_untracked="-u" || no_untracked=""
|
||||
if [ "$(checkForHgDir)" == "true" ]; then
|
||||
if [ "$(hg -R $path status -admr $no_untracked)" != "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# check if a hg repo exists in the directory
|
||||
checkForHgDir()
|
||||
{
|
||||
if [ "$(hg -R $path branch)" != "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
fi
|
||||
}
|
||||
|
||||
# return branch name if there is one
|
||||
getBranch()
|
||||
{
|
||||
if [ $(checkForHgDir) == "true" ]; then
|
||||
echo $(hg -R $path branch)
|
||||
else
|
||||
echo $no_repo_message
|
||||
fi
|
||||
}
|
||||
|
||||
# return the final message for the status bar
|
||||
getMessage()
|
||||
{
|
||||
if [ $(checkForHgDir) == "true" ]; then
|
||||
branch="$(getBranch)"
|
||||
output=""
|
||||
|
||||
if [ $(checkForChanges) == "true" ]; then
|
||||
|
||||
changes="$(getChanges)"
|
||||
|
||||
if [ "${hide_status}" == "false" ]; then
|
||||
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
|
||||
output=$(echo "${changes} $branch")
|
||||
else
|
||||
output=$(echo "$diff_symbol ${changes} $branch")
|
||||
fi
|
||||
else
|
||||
if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then
|
||||
output=$(echo "$branch")
|
||||
else
|
||||
output=$(echo "$diff_symbol $branch")
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
if [ $(checkEmptySymbol $current_symbol) == "true" ]; then
|
||||
output=$(echo "$branch")
|
||||
else
|
||||
output=$(echo "$current_symbol $branch")
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$output"
|
||||
else
|
||||
echo $no_repo_message
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
path=$(getPaneDir)
|
||||
getMessage
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
||||
49
data/tmux/plugins/tmux/scripts/krbtgt.sh
Executable file
49
data/tmux/plugins/tmux/scripts/krbtgt.sh
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
principal=$1
|
||||
label=$2
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
if [ -n "$principal" ]; then
|
||||
_principal=$principal
|
||||
if ! [[ "$_principal" =~ "@" ]]; then
|
||||
_principal="$_principal@"
|
||||
fi
|
||||
krb_principal_tgt_cache=$(klist -lan | awk -v krb_principal="^$_principal" '$0 ~ krb_principal {print $2}')
|
||||
if [ -n "$krb_principal_tgt_cache" ]; then
|
||||
krb_tgt_expire=$(date '+%H:%M:%S' -d "$(klist $krb_principal_tgt_cache | awk '/krbtgt/ {print $3,$4}')")
|
||||
else
|
||||
krb_tgt_expire=""
|
||||
fi
|
||||
fi
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
OUTPUT_STRING=""
|
||||
if [ -z "$principal" ]; then
|
||||
OUTPUT_STRING="no principal configured"
|
||||
fi
|
||||
|
||||
if [ -z "$krb_tgt_expire" ]; then
|
||||
OUTPUT_STRING="$principal -"
|
||||
else
|
||||
OUTPUT_STRING="${principal} ${krb_tgt_expire}"
|
||||
fi
|
||||
|
||||
if [ "$label" = "" ]; then
|
||||
echo "${OUTPUT_STRING}"
|
||||
else
|
||||
echo "${label} ${OUTPUT_STRING}"
|
||||
fi
|
||||
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
91
data/tmux/plugins/tmux/scripts/kubernetes_context.sh
Executable file
91
data/tmux/plugins/tmux/scripts/kubernetes_context.sh
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
hide_arn_from_cluster=$1
|
||||
extract_account=$2
|
||||
hide_user=$3
|
||||
just_current_context=$4
|
||||
hide_no_config=$5
|
||||
label=$6
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
current_context=$(kubectl config view --minify --output 'jsonpath={.current-context}'; echo)
|
||||
current_user=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.user}'; echo)
|
||||
current_cluster=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.cluster}'; echo)
|
||||
current_namespace=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.namespace}'; echo)
|
||||
|
||||
current_account_id=""
|
||||
if [[ "$current_cluster" =~ ^arn:(aws|aws-[a-z\-]*-gov):eks:[a-z0-9\-]*:[0-9]*:cluster/[a-z0-9\-]*$ ]]; then
|
||||
if [ "$extract_account" = "true" ]; then
|
||||
current_account_id=$(echo "$current_cluster" | cut -d':' -f5)
|
||||
fi
|
||||
if [ "$hide_arn_from_cluster" = "true" ]; then
|
||||
current_cluster=${current_cluster##*/}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$hide_user" = "true" ]; then
|
||||
current_user=""
|
||||
fi
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
OUTPUT_STRING=""
|
||||
|
||||
if [ ! -f ~/.kube/config ] && [ "$hide_no_config" = "true" ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$just_current_context" = "true" ]
|
||||
then
|
||||
echo "$current_context"
|
||||
else
|
||||
getFullMessage
|
||||
fi
|
||||
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
getFullMessage()
|
||||
{
|
||||
if [ ! -z "$current_account_id" ]
|
||||
then
|
||||
OUTPUT_STRING="${current_account_id}/"
|
||||
fi
|
||||
|
||||
if [ ! -z "$current_user" ]
|
||||
then
|
||||
OUTPUT_STRING="${current_user}@"
|
||||
fi
|
||||
|
||||
if [ ! -z "$current_cluster" ]
|
||||
then
|
||||
OUTPUT_STRING="${OUTPUT_STRING}${current_cluster}"
|
||||
fi
|
||||
|
||||
if [ ! -z "$current_namespace" ]
|
||||
then
|
||||
OUTPUT_STRING="${OUTPUT_STRING}:${current_namespace}"
|
||||
fi
|
||||
|
||||
if [ "$OUTPUT_STRING" = "" ]
|
||||
then
|
||||
OUTPUT_STRING="kubeconfig not valid"
|
||||
fi
|
||||
|
||||
if [ "$label" = "" ]
|
||||
then
|
||||
echo "${OUTPUT_STRING}"
|
||||
else
|
||||
echo "${label} ${OUTPUT_STRING}"
|
||||
fi
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
342
data/tmux/plugins/tmux/scripts/libre.sh
Executable file
342
data/tmux/plugins/tmux/scripts/libre.sh
Executable file
|
|
@ -0,0 +1,342 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# TmuxLibre: Monitor Your Blood Glucose Levels in Tmux
|
||||
################################################################################
|
||||
#
|
||||
# This script retrieves and displays continuous glucose monitoring (CGM) data
|
||||
# from the LibreView API. It caches the data to minimize API requests and
|
||||
# displays the latest glucose level along with a trend indicator in a Tmux
|
||||
# status bar.
|
||||
#
|
||||
# Features:
|
||||
# - Fetches glucose data from the LibreView API.
|
||||
# - Caches data to reduce the number of API requests.
|
||||
# - Displays glucose level and trend in a Tmux status bar.
|
||||
# - Rotates log files to manage log size.
|
||||
#
|
||||
# How It Works:
|
||||
# 1. The script loads configuration settings from ~/.tmuxlibre.conf.
|
||||
# 2. If necessary, it creates a default configuration file and exits.
|
||||
# 3. The script checks the cache for recent data.
|
||||
# 4. If the cache is outdated, it logs into the LibreView API and fetches new data.
|
||||
# 5. The script parses the data and determines the glucose trend.
|
||||
# 6. Finally, it outputs the glucose level and trend for display in Tmux.
|
||||
#
|
||||
# Configuration:
|
||||
# - Create or edit ~/.tmuxlibre.conf with the following settings:
|
||||
# LIBREVIEW_API_URL="https://api-de.libreview.io"
|
||||
# CACHE_FILE="/tmp/tmuxlibre_cache.json"
|
||||
# CACHE_DURATION=180
|
||||
# LOG_FILE="/tmp/tmuxlibre.log"
|
||||
# LOG_MAX_SIZE=2000000
|
||||
# LIBREVIEW_EMAIL="your_email"
|
||||
# LIBREVIEW_PASSWORD="your_password"
|
||||
#
|
||||
# Dependencies:
|
||||
# - curl
|
||||
# - jq
|
||||
# - bc
|
||||
# - gzip
|
||||
################################################################################
|
||||
|
||||
# Setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# Load utils
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
# Constants (Default values, can be overridden by config)
|
||||
BASE_URL="${LIBREVIEW_API_URL:-https://api-de.libreview.io}"
|
||||
CACHE_FILE="/tmp/tmuxlibre_cache.json"
|
||||
CACHE_DURATION=180 # Cache duration in seconds (3 minutes)
|
||||
LOG_FILE="/tmp/tmuxlibre.log"
|
||||
LOG_MAX_SIZE=2000000 # 2MB
|
||||
CONFIG_FILE="$HOME/.tmuxlibre.conf"
|
||||
TOKEN_FILE="/tmp/tmuxlibre_token.json" # File to store the token and its expiry
|
||||
|
||||
HEADERS=(
|
||||
-H "accept-encoding: gzip"
|
||||
-H "cache-control: no-cache"
|
||||
-H "connection: Keep-Alive"
|
||||
-H "content-type: application/json"
|
||||
-H "product: llu.android"
|
||||
-H "version: 4.7"
|
||||
)
|
||||
|
||||
# Function to log messages to the log file and rotate the log if needed
|
||||
# Input: Log message as a string
|
||||
log() {
|
||||
echo "$(date +'%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
|
||||
rotate_log
|
||||
}
|
||||
|
||||
# Function to get the file size in bytes
|
||||
# Input: File path as a string
|
||||
# Output: File size in bytes as a string
|
||||
get_file_size()
|
||||
{
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
du -b "$1" | cut -f1
|
||||
;;
|
||||
Darwin|FreeBSD)
|
||||
du -k "$1" | cut -f1
|
||||
;;
|
||||
*)
|
||||
log "Unsupported OS: $(uname -s)"
|
||||
echo 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to rotate the log file if it exceeds the maximum size
|
||||
# No input, no output
|
||||
rotate_log() {
|
||||
if [ -f "$LOG_FILE" ]; then
|
||||
log_size=$(get_file_size "$LOG_FILE")
|
||||
if [ "$log_size" -gt $LOG_MAX_SIZE ]; then
|
||||
mv "$LOG_FILE" "$LOG_FILE.1"
|
||||
gzip "$LOG_FILE.1"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to load configuration settings from the config file
|
||||
# Creates a default config file if it doesn't exist
|
||||
# No input, no output
|
||||
load_config() {
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
cat <<EOL > "$CONFIG_FILE"
|
||||
# Configuration file for tmuxlibre
|
||||
# Uncomment and set the following variables as needed:
|
||||
|
||||
# LIBREVIEW_API_URL="https://api-de.libreview.io"
|
||||
# CACHE_FILE="/tmp/tmuxlibre_cache.json"
|
||||
# CACHE_DURATION=180
|
||||
# LOG_FILE="/tmp/tmuxlibre.log"
|
||||
# LOG_MAX_SIZE=2000000
|
||||
# LIBREVIEW_EMAIL=""
|
||||
# LIBREVIEW_PASSWORD=""
|
||||
EOL
|
||||
log "Configuration file created: $CONFIG_FILE"
|
||||
echo "🦋 CONFIG FILE CREATED, PLEASE CONFIGURE AND RE-RUN ❌"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "$CONFIG_FILE"
|
||||
|
||||
: "${LIBREVIEW_API_URL:=$BASE_URL}"
|
||||
: "${CACHE_FILE:=$CACHE_FILE}"
|
||||
: "${CACHE_DURATION:=$CACHE_DURATION}"
|
||||
: "${LOG_FILE:=$LOG_FILE}"
|
||||
: "${LOG_MAX_SIZE:=$LOG_MAX_SIZE}"
|
||||
|
||||
if [ -z "$LIBREVIEW_EMAIL" ] || [ -z "$LIBREVIEW_PASSWORD" ]; then
|
||||
if grep -q '^[^#]' "$CONFIG_FILE"; then
|
||||
log "Email and password must be set in the configuration file"
|
||||
echo "🦋 CHECK CONFIG ❌"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to log in to the LibreView API and retrieve an authentication token
|
||||
# This function also checks if a cached token is available and still valid
|
||||
# Input: Email and password as strings
|
||||
# Output: Authentication token as a string
|
||||
login() {
|
||||
local email=$1
|
||||
local password=$2
|
||||
|
||||
# Check for a cached token
|
||||
if [ -f "$TOKEN_FILE" ]; then
|
||||
token_data=$(cat "$TOKEN_FILE")
|
||||
token=$(echo "$token_data" | jq -r '.token')
|
||||
expires=$(echo "$token_data" | jq -r '.expires')
|
||||
|
||||
current_time=$(date +%s)
|
||||
if (( current_time < expires )); then
|
||||
echo "$token"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# No valid cached token, perform login
|
||||
local endpoint="/llu/auth/login"
|
||||
local payload="{\"email\": \"$email\", \"password\": \"$password\"}"
|
||||
|
||||
response=$(curl -s -X POST "$LIBREVIEW_API_URL$endpoint" "${HEADERS[@]}" -d "$payload" --compressed)
|
||||
if [ $? -ne 0 ]; then
|
||||
log "HTTP error occurred during login"
|
||||
log "Response: $response"
|
||||
echo "🦋 NO DATA ❌"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Login response: $response"
|
||||
|
||||
response=$(echo "$response" | tr -d '\0' | tr -cd '\11\12\15\40-\176')
|
||||
token=$(echo "$response" | jq -r '.data.authTicket.token' 2>/dev/null)
|
||||
expires=$(echo "$response" | jq -r '.data.authTicket.expires' 2>/dev/null)
|
||||
if [ -z "$token" ] || [ "$token" == "null" ]; then
|
||||
log "Failed to retrieve token from login response"
|
||||
echo "🦋 NO DATA ❌"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "{\"token\": \"$token\", \"expires\": $expires}" > "$TOKEN_FILE"
|
||||
|
||||
echo "$token"
|
||||
}
|
||||
|
||||
# Function to get patient connections from the LibreView API
|
||||
# Input: Authentication token as a string
|
||||
# Output: Patient connections data as a JSON string
|
||||
get_patient_connections() {
|
||||
local token=$1
|
||||
local endpoint="/llu/connections"
|
||||
local auth_header="Authorization: Bearer $token"
|
||||
|
||||
response=$(curl -s -X GET "$LIBREVIEW_API_URL$endpoint" "${HEADERS[@]}" -H "$auth_header" --compressed)
|
||||
if [ $? -ne 0 ]; then
|
||||
log "HTTP error occurred during fetching patient connections"
|
||||
log "Response: $response"
|
||||
echo "🦋 NO DATA ❌"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Patient connections response: $response"
|
||||
|
||||
data=$(echo "$response" | jq -c '.data' 2>/dev/null)
|
||||
if [ -z "$data" ] || [ "$data" == "null" ]; then
|
||||
log "No patient connections found"
|
||||
echo "🦋 NO DATA ❌"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$data"
|
||||
}
|
||||
|
||||
# Function to get CGM data for a patient from the LibreView API
|
||||
# Input: Authentication token and patient ID as strings
|
||||
# Output: CGM data as a JSON string
|
||||
get_cgm_data() {
|
||||
local token=$1
|
||||
local patient_id=$2
|
||||
local endpoint="/llu/connections/$patient_id/graph"
|
||||
local auth_header="Authorization: Bearer $token"
|
||||
|
||||
response=$(curl -s -X GET "$LIBREVIEW_API_URL$endpoint" "${HEADERS[@]}" -H "$auth_header" --compressed)
|
||||
if [ $? -ne 0 ]; then
|
||||
log "HTTP error occurred during fetching CGM data"
|
||||
log "Response: $response"
|
||||
echo "🦋 NO DATA ❌"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "CGM data response: $response"
|
||||
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# Function to get the emoji representing a trend based on a given input number
|
||||
# Input: A number between 1 and 5 representing the trend
|
||||
# 1 - SingleDown
|
||||
# 2 - FortyFiveDown
|
||||
# 3 - Flat
|
||||
# 4 - FortyFiveUp
|
||||
# 5 - SingleUp
|
||||
# Output: The corresponding emoji for the trend
|
||||
get_trend() {
|
||||
case $1 in
|
||||
1)
|
||||
echo "⬇️" # SingleDown
|
||||
;;
|
||||
2)
|
||||
echo "↘️" # FortyFiveDown
|
||||
;;
|
||||
3)
|
||||
echo "➡️" # Flat
|
||||
;;
|
||||
4)
|
||||
echo "↗️" # FortyFiveUp
|
||||
;;
|
||||
5)
|
||||
echo "⬆️" # SingleUp
|
||||
;;
|
||||
*)
|
||||
echo "🤡"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Function to cache CGM data to a file
|
||||
# Input: CGM data as a JSON string
|
||||
cache_data() {
|
||||
local data=$1
|
||||
echo "{\"timestamp\": $(date +%s), \"data\": $data}" > "$CACHE_FILE"
|
||||
}
|
||||
|
||||
# Function to load cached CGM data from a file
|
||||
# Output: Cached CGM data as a JSON string, or an empty JSON object if the cache is outdated
|
||||
load_cached_data() {
|
||||
if [ ! -f "$CACHE_FILE" ]; then
|
||||
echo "{}"
|
||||
return
|
||||
fi
|
||||
|
||||
cached=$(cat "$CACHE_FILE")
|
||||
cached_timestamp=$(echo "$cached" | jq -r '.timestamp' | awk '{printf "%d\n", $1}')
|
||||
current_timestamp=$(date +%s)
|
||||
|
||||
if (( current_timestamp - cached_timestamp > CACHE_DURATION )); then
|
||||
echo "{}"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "$cached" | jq -c '.data'
|
||||
}
|
||||
|
||||
# Function to get CGM data, either from the cache or by fetching it from the API
|
||||
# No input, outputs the glucose level and trend for display in Tmux
|
||||
get_data() {
|
||||
cached_data=$(load_cached_data)
|
||||
if [ "$cached_data" != "{}" ]; then
|
||||
cgm_data="$cached_data"
|
||||
else
|
||||
token=$(login "$LIBREVIEW_EMAIL" "$LIBREVIEW_PASSWORD")
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
patient_data=$(get_patient_connections "$token")
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
patient_id=$(echo "$patient_data" | jq -r '.[0].patientId' 2>/dev/null)
|
||||
if [ -z "$patient_id" ];then
|
||||
log "Patient ID not found in patient connections"
|
||||
echo "🦋 NO DATA ❌"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cgm_data=$(get_cgm_data "$token" "$patient_id")
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cache_data "$cgm_data"
|
||||
fi
|
||||
|
||||
value=$(echo "$cgm_data" | jq -r '.data.connection.glucoseMeasurement.Value' 2>/dev/null)
|
||||
trendarrow=$(echo "$cgm_data" | jq -r '.data.connection.glucoseMeasurement.TrendArrow' 2>/dev/null)
|
||||
trend=$(get_trend "$trendarrow")
|
||||
|
||||
echo "🦋 $value $trend"
|
||||
}
|
||||
|
||||
# Load config and execute the main logic
|
||||
load_config
|
||||
get_data
|
||||
239
data/tmux/plugins/tmux/scripts/mac-player.sh
Executable file
239
data/tmux/plugins/tmux/scripts/mac-player.sh
Executable file
|
|
@ -0,0 +1,239 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$current_dir/utils.sh"
|
||||
|
||||
|
||||
function trackStatus() {
|
||||
local active_player
|
||||
local pause_icon="$1"
|
||||
local play_icon="$2"
|
||||
|
||||
active_player=$(osascript -e "
|
||||
property playerList : {\"Spotify\", \"Music\", \"Safari\", \"Google Chrome\"}
|
||||
property nativePlayerList : {\"Spotify\", \"Music\"}
|
||||
|
||||
|
||||
-- Detect the Player being used
|
||||
on detectPlayer()
|
||||
repeat with appName in playerList
|
||||
set currentApp to contents of appName
|
||||
-- process checker
|
||||
-- native and browser checker
|
||||
if (running of application currentApp) then
|
||||
if (currentApp is not in nativePlayerList) then
|
||||
return browserPlayer(currentApp)
|
||||
else
|
||||
return nativePlayer(currentApp)
|
||||
end if
|
||||
end if
|
||||
end repeat
|
||||
|
||||
return \"No App Supported\"
|
||||
end detectPlayer
|
||||
|
||||
|
||||
-- nativePlayer Function: supports spotify and apple-music
|
||||
on nativePlayer(nativeName)
|
||||
if not (running of application nativeName) then return \"not running\"
|
||||
if nativeName is \"Spotify\" then
|
||||
tell application \"Spotify\"
|
||||
if player state is stopped then return \"stopped\"
|
||||
set trackArtist to artist of current track
|
||||
set trackName to name of current track
|
||||
if player state is paused then
|
||||
return \"$pause_icon \" & trackArtist & \" - \" & trackName
|
||||
else
|
||||
return \"$play_icon \" & trackArtist & \" - \" & trackName
|
||||
end if
|
||||
|
||||
end tell
|
||||
else if nativeName is \"Music\" then
|
||||
tell application \"Music\"
|
||||
if player state is stopped then return \"stopped\"
|
||||
set trackArtist to artist of current track
|
||||
set trackName to name of current track
|
||||
if player state is paused then
|
||||
return \"$pause_icon \" & trackArtist & \" - \" & trackName
|
||||
else
|
||||
return \"$play_icon \" & trackArtist & \" - \" & trackName
|
||||
end if
|
||||
|
||||
end tell
|
||||
end if
|
||||
|
||||
end nativePlayer
|
||||
|
||||
-- browserPlayer Function: supports Safari and Google Chrome
|
||||
on browserPlayer(browserName)
|
||||
if (running of application \"Safari\") and (browserName is \"Safari\") then
|
||||
tell application \"Safari\"
|
||||
set currentTab to the front document
|
||||
set currentURL to URL of currentTab
|
||||
set pageTitle to name of currentTab
|
||||
end tell
|
||||
else if (running of application \"Google Chrome\") and (browserName is \"Google Chrome\") then
|
||||
tell application \"Google Chrome\"
|
||||
set currentTab to active tab of front window
|
||||
--- set currentTab to active tab of front window
|
||||
set currentURL to URL of currentTab
|
||||
set pageTitle to title of currentTab
|
||||
end tell
|
||||
else
|
||||
return \"Not Supported\"
|
||||
end if
|
||||
|
||||
|
||||
-- Check if it's a YouTube video page
|
||||
if currentURL contains \"youtube.com/watch\" then
|
||||
-- YouTube video titles usually follow this format: \"Artist - Track Name\"
|
||||
set AppleScript's text item delimiters to \" - \"
|
||||
set titleParts to text items of pageTitle
|
||||
|
||||
if (count of titleParts) ≥ 2 then
|
||||
set artistName to item 1 of titleParts
|
||||
set trackName to item 2 of titleParts
|
||||
--- display dialog \"Artist: \" & artistName & return & \"Track: \" & trackName
|
||||
return artistName & \" - \" & trackName
|
||||
else
|
||||
--- display dialog \"Could not parse artist and track from: \" & pageTitle
|
||||
return \"can't encode\"
|
||||
end if
|
||||
-- Check if it's a Spotify video page
|
||||
else if currentURL contains \"open.spotify.com\" then
|
||||
-- Spotify video titles usually follow this format: \"Artist • Track Name\"
|
||||
set AppleScript's text item delimiters to \" • \"
|
||||
set titleParts to text items of pageTitle
|
||||
|
||||
if (count of titleParts) ≥ 2 then
|
||||
set artistName to item 1 of titleParts
|
||||
set trackName to item 2 of titleParts
|
||||
--- display dialog \"Artist: \" & artistName & return & \"Track: \" & trackName
|
||||
return artistName & \" - \" & trackName
|
||||
else
|
||||
--- display dialog \"Could not parse artist and track from: \" & pageTitle
|
||||
return \"can't encode\"
|
||||
end if
|
||||
|
||||
|
||||
else
|
||||
return \"No active Tab\"
|
||||
end if
|
||||
|
||||
end browserPlayer
|
||||
|
||||
|
||||
detectPlayer()
|
||||
")
|
||||
|
||||
|
||||
case "$active_player" in
|
||||
"not running") echo "not running" ;;
|
||||
"stopped") echo "stopped" ;;
|
||||
"can't encode") echo "unable to encode" ;;
|
||||
"Not Supported") echo "not supported" ;;
|
||||
|
||||
*) echo "$active_player" ;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
function sliceTrack()
|
||||
{
|
||||
local str="$1"
|
||||
local std="$2"
|
||||
local len=${#str}
|
||||
|
||||
local result=""
|
||||
|
||||
if [[ $len > $std ]]; then
|
||||
result="${str:0:$std}"
|
||||
result+="..."
|
||||
else
|
||||
result=$str
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
|
||||
function remoteControl() {
|
||||
local toggle_button="$1"
|
||||
local back_button="$2"
|
||||
local next_button="$3"
|
||||
local app_controlled="$4"
|
||||
|
||||
if [[ $app_controlled == "Spotify" ]] || [[ $app_controlled == "Music" ]]; then
|
||||
|
||||
if [[ $app_controlled == "Music" ]]; then
|
||||
back="osascript -e 'tell application \"$app_controlled\" to back track'"
|
||||
else
|
||||
back="osascript -e 'tell application \"$app_controlled\" to previous track'"
|
||||
fi
|
||||
|
||||
toggle="osascript -e 'tell application \"$app_controlled\" to playpause'"
|
||||
next="osascript -e 'tell application \"$app_controlled\" to play next track'"
|
||||
|
||||
tmux unbind-key "$toggle_button"
|
||||
tmux unbind-key "$back_button"
|
||||
tmux unbind-key "$next_button"
|
||||
|
||||
tmux bind-key "$toggle_button" run-shell "$toggle"
|
||||
tmux bind-key "$back_button" run-shell "$back"
|
||||
tmux bind-key "$next_button" run-shell "$next"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
# save buffer to prevent lag
|
||||
local cache_file="/tmp/tmux_mac_player_cache"
|
||||
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
|
||||
# Active Player variables
|
||||
PLAY_ICON=$(get_tmux_option "@dracula-mac-player-play-icon" "♪")
|
||||
PAUSE_ICON=$(get_tmux_option "@dracula-mac-player-pause-icon" "❚❚ ")
|
||||
MAX_LENGTH=$(get_tmux_option "@dracula-mac-player-length" 25)
|
||||
|
||||
# Remote variables
|
||||
REMOTE_ACCESS=$(get_tmux_option "@dracula-mac-player-remote" "false")
|
||||
REMOTE_APP=$(get_tmux_option "@dracula-mac-player-app" "Spotify")
|
||||
|
||||
# os checker
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remote Access
|
||||
if [[ "$REMOTE_ACCESS" == "true" ]]; then
|
||||
# Remote Control Buttons Customizations
|
||||
PLAY_PAUSE_BUTTON=$(get_tmux_option "@dracula-mac-player-remote-play-pause" "P")
|
||||
BACK_BUTTON=$(get_tmux_option "@dracula-mac-player-remote-back" "R")
|
||||
NEXT_BUTTON=$(get_tmux_option "@dracula-mac-player-remote-next" "N")
|
||||
|
||||
remoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$NEXT_BUTTON" "$REMOTE_APP"
|
||||
else
|
||||
# Clean up when remote is disabled
|
||||
tmux set -g @dracula-mac-player-remote-play-pause ""
|
||||
tmux set -g @dracula-mac-player-remote-back ""
|
||||
tmux set -g @dracula-mac-player-remote-next ""
|
||||
tmux unbind-key "$PLAY_PAUSE_BUTTON" 2>/dev/null
|
||||
tmux unbind-key "$BACK_BUTTON" 2>/dev/null
|
||||
tmux unbind-key "$NEXT_BUTTON" 2>/dev/null
|
||||
fi
|
||||
|
||||
if [ ! -f "$cache_file" ] || [ $(($(date +%s) - $(stat -f%c "$cache_file"))) -ge "$RATE" ]; then
|
||||
local full_track
|
||||
|
||||
full_track=$(trackStatus "$PAUSE_ICON" "$PLAY_ICON")
|
||||
sliceTrack "$full_track" "$MAX_LENGTH" > "$cache_file"
|
||||
fi
|
||||
|
||||
cat "$cache_file"
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
25
data/tmux/plugins/tmux/scripts/mpc.sh
Executable file
25
data/tmux/plugins/tmux/scripts/mpc.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
|
||||
if ! command -v mpc &> /dev/null
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FORMAT=$(get_tmux_option "@dracula-mpc-format" "%title% - %artist%")
|
||||
mpc_playback=$(mpc current -f "${FORMAT}")
|
||||
echo ${mpc_playback}
|
||||
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
31
data/tmux/plugins/tmux/scripts/network-public-ip.sh
Executable file
31
data/tmux/plugins/tmux/scripts/network-public-ip.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
DATAFILE="/tmp/.dracula-tmux-public-ip-data"
|
||||
LAST_EXEC_FILE="/tmp/.dracula-tmux-public-ip-last-exec"
|
||||
INTERVAL=1200
|
||||
|
||||
main() {
|
||||
local _current_dir _last _now
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
_last=$(cat "$LAST_EXEC_FILE" 2>/dev/null || echo 0)
|
||||
_now=$(date +%s)
|
||||
|
||||
source $current_dir/utils.sh
|
||||
|
||||
if (((_now - _last) > INTERVAL)); then
|
||||
IP_SERVER="ifconfig.me"
|
||||
ip=$(curl -s "$IP_SERVER")
|
||||
|
||||
network_public_ip_label=$(get_tmux_option "@dracula-network-public-ip-label" "IP")
|
||||
echo "$network_public_ip_label$ip" > "${DATAFILE}"
|
||||
printf '%s' "$_now" > "${LAST_EXEC_FILE}"
|
||||
fi
|
||||
|
||||
cat "${DATAFILE}"
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
93
data/tmux/plugins/tmux/scripts/network.sh
Executable file
93
data/tmux/plugins/tmux/scripts/network.sh
Executable file
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
# set your own hosts so that a wifi is recognised even without internet access
|
||||
HOSTS=$(get_tmux_option "@dracula-network-hosts" "google.com github.com example.com")
|
||||
wifi_label=$(get_tmux_option "@dracula-network-wifi-label" "")
|
||||
ethernet_label=$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")
|
||||
|
||||
_get_wifi_ifname() {
|
||||
if ! scutil <<< list |
|
||||
awk -F/ '/Setup:.*AirPort$/{i=$(NF-1);exit} END {if(i) {print i} else {exit 1}}'; then
|
||||
scutil <<< list | awk -F/ '/en[0-9]+\/AirPort$/ {print $(NF-1);exit}'
|
||||
fi
|
||||
}
|
||||
|
||||
get_ssid()
|
||||
{
|
||||
# Check OS
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
if grep -qi microsoft /proc/version 2>/dev/null && command -v netsh.exe &>/dev/null; then
|
||||
SSID=$(netsh.exe wlan show interfaces 2>/dev/null | sed -nr 's/^\s*SSID\s*:\s*(.+)/\1/p' | head -1 | tr -d '\r')
|
||||
else
|
||||
SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p')
|
||||
fi
|
||||
if [ -n "$SSID" ]; then
|
||||
echo "$wifi_label$SSID"
|
||||
else
|
||||
echo "$ethernet_label"
|
||||
fi
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
local ifname
|
||||
local wifi_network
|
||||
local airport
|
||||
|
||||
ifname=$(_get_wifi_ifname)
|
||||
|
||||
# string manipulation required to remove the minor version of the macos version (e.g. x.y.z removes .z)
|
||||
# this is required to prevent issues in version detection
|
||||
#
|
||||
# Note: Minor versions do not introduce substantial changes generally only fix bugs
|
||||
macos_version=$(sw_vers -productVersion)
|
||||
macos_version=${macos_version%.*}
|
||||
|
||||
if (( $(echo "$macos_version > 25.0" | bc -l) )); then
|
||||
wifi_network=$(networksetup -listpreferredwirelessnetworks "$ifname" | awk 'NR==2 && sub("\t","") { print; exit }')
|
||||
else
|
||||
wifi_network=$(ipconfig getsummary "$ifname" | awk -F ' SSID : ' '/ SSID : / {print $2}')
|
||||
fi
|
||||
|
||||
airport=$(networksetup -getairportnetwork "$ifname" | cut -d ':' -f 2 | head -n 1)
|
||||
|
||||
airport=$(echo "$airport" | sed 's/^[[:blank:]]*//g')
|
||||
if [[ $airport != "You are not associated with an AirPort network." ]]; then
|
||||
echo "$wifi_label$airport" | sed 's/^[[:blank:]]*//g'
|
||||
elif [[ $wifi_network != "" ]]; then
|
||||
echo "$wifi_label$wifi_network" | sed 's/^[[:blank:]]*//g'
|
||||
else
|
||||
echo "$ethernet_label"
|
||||
fi
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# leaving empty - TODO - windows compatability
|
||||
;;
|
||||
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
network="$(get_tmux_option "@dracula-network-offline-label" "Offline")"
|
||||
for host in $HOSTS; do
|
||||
if ping -q -c 1 -W 1 "$host" &>/dev/null; then
|
||||
network="$(get_ssid)"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$network"
|
||||
}
|
||||
|
||||
#run main driver function
|
||||
main
|
||||
123
data/tmux/plugins/tmux/scripts/network_bandwidth.sh
Executable file
123
data/tmux/plugins/tmux/scripts/network_bandwidth.sh
Executable file
|
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# INTERVAL is equal to 1s because we want to express the bandwidth in sec
|
||||
readonly INTERVAL=1
|
||||
|
||||
# UPLOAD and DOWNLOAD index
|
||||
readonly UPLOAD=0
|
||||
readonly DOWNLOAD=1
|
||||
|
||||
# SIZE index are the multiple of the unit byte and value the internationally recommended unit symbol in sec
|
||||
readonly SIZE=(
|
||||
[1]='B/s'
|
||||
[1024]='kB/s'
|
||||
[1048576]='MB/s'
|
||||
[1073741824]='GB/s'
|
||||
)
|
||||
|
||||
# interface_get try to automaticaly get the used interface if network_name is empty
|
||||
interface_get() {
|
||||
name="$(tmux show-option -gqv "@dracula-network-bandwidth")"
|
||||
|
||||
if [[ -z $name ]]; then
|
||||
case "$(uname -s)" in
|
||||
Linux)
|
||||
if type ip >/dev/null; then
|
||||
name="$(ip -o route get 192.168.0.0 | awk '{print $5}')"
|
||||
fi
|
||||
;;
|
||||
Darwin)
|
||||
if type route >/dev/null; then
|
||||
name="$(route -n get 192.168.0.0 2>/dev/null | awk '/interface: / {print $2}')"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "$name"
|
||||
}
|
||||
|
||||
# interface_bytes give an interface name and return both tx/rx Bytes, separated by whitespace (upload first)
|
||||
interface_bytes() {
|
||||
case "$(uname -s)" in
|
||||
Linux)
|
||||
upload=$(cat "/sys/class/net/$1/statistics/tx_bytes")
|
||||
download=$(cat "/sys/class/net/$1/statistics/rx_bytes")
|
||||
|
||||
echo "$upload $download"
|
||||
;;
|
||||
Darwin)
|
||||
# column 7 is Ibytes (in bytes, rx, download) and column 10 is Obytes (out bytes, tx, upload)
|
||||
netstat -nbI "$1" | tail -n1 | awk '{print $10 " " $7}'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# get_bandwidth return the number of bytes exchanged for tx and rx
|
||||
get_bandwidth() {
|
||||
local upload=0
|
||||
local download=0
|
||||
|
||||
IFS=' ' read -r upload download <<< "$(interface_bytes "$1")"
|
||||
|
||||
# wait for interval to calculate the difference
|
||||
sleep "$INTERVAL"
|
||||
|
||||
IFS=' ' read -r new_upload new_download <<< "$(interface_bytes "$1")"
|
||||
|
||||
upload=$(( $new_upload - $upload ))
|
||||
download=$(( $new_download - $download ))
|
||||
|
||||
# set to 0 by default
|
||||
echo "${upload:-0} ${download:-0}"
|
||||
}
|
||||
|
||||
# bandwidth_to_unit convert bytes into its highest unit and add unit symbol in sec
|
||||
bandwidth_to_unit() {
|
||||
local size=1
|
||||
for i in "${!SIZE[@]}"; do
|
||||
if (($1 < i)); then
|
||||
break
|
||||
fi
|
||||
|
||||
size="$i"
|
||||
done
|
||||
|
||||
local result="0.00"
|
||||
if (($1 != 0)); then
|
||||
result="$(awk -v a="$1" -v b="$size" 'BEGIN { printf "%.2f\n", a / b }' </dev/null)"
|
||||
fi
|
||||
|
||||
echo "$result ${SIZE[$size]}"
|
||||
}
|
||||
|
||||
main() {
|
||||
counter=0
|
||||
bandwidth=()
|
||||
|
||||
network_name=""
|
||||
show_interface="$(tmux show-option -gqv "@dracula-network-bandwidth-show-interface")"
|
||||
interval_update="$(tmux show-option -gqv "@dracula-network-bandwidth-interval")"
|
||||
|
||||
if [[ -z $interval_update ]]; then
|
||||
interval_update=0
|
||||
fi
|
||||
|
||||
while true; do
|
||||
if ((counter == 0)); then
|
||||
counter=60
|
||||
network_name="$(interface_get)"
|
||||
fi
|
||||
|
||||
IFS=" " read -ra bandwidth <<<"$(get_bandwidth "$network_name")"
|
||||
|
||||
if [[ $show_interface == "true" ]]; then echo -n "[$network_name] "; fi
|
||||
printf "↓ %6s %-4s • ↑ %6s %-4s\n" $(bandwidth_to_unit "${bandwidth[$DOWNLOAD]}") $(bandwidth_to_unit "${bandwidth[$UPLOAD]}")
|
||||
|
||||
((counter = counter - 1))
|
||||
sleep "$interval_update"
|
||||
done
|
||||
}
|
||||
|
||||
#run main driver
|
||||
main
|
||||
35
data/tmux/plugins/tmux/scripts/network_ping.sh
Executable file
35
data/tmux/plugins/tmux/scripts/network_ping.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# configuration
|
||||
# @dracula-ping-server "example.com"
|
||||
# @dracula-ping-rate 5
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
ping_function() {
|
||||
case $(uname -s) in
|
||||
Linux | Darwin)
|
||||
# storing the hostname/IP in the variable PINGSERVER, default is google.com
|
||||
pingserver=$(get_tmux_option "@dracula-ping-server" "google.com")
|
||||
pingtime=$(ping -c 1 "$pingserver" | tail -1 | awk '{print $4}' | cut -d '/' -f 2)
|
||||
echo "$pingtime ms"
|
||||
;;
|
||||
|
||||
CYGWIN* | MINGW32* | MSYS* | MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
echo $(ping_function)
|
||||
RATE=$(get_tmux_option "@dracula-ping-rate" 5)
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
||||
113
data/tmux/plugins/tmux/scripts/network_vpn.sh
Executable file
113
data/tmux/plugins/tmux/scripts/network_vpn.sh
Executable file
|
|
@ -0,0 +1,113 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
|
||||
|
||||
vpn_function() {
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
|
||||
verbose=$(get_tmux_option "@dracula-network-vpn-verbose" false)
|
||||
|
||||
# Show IP of tun0 if connected
|
||||
vpn=$(ip -o -4 addr show dev tun0 | awk '{print $4}' | cut -d/ -f1)
|
||||
|
||||
which -s tailscale > /dev/null
|
||||
tailscale_installed=$?
|
||||
|
||||
if [[ $vpn =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
|
||||
if $verbose; then
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" " ")
|
||||
echo "$vpn_label$vpn"
|
||||
else
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" "VPN-ON")
|
||||
echo "$vpn_label"
|
||||
fi
|
||||
elif [ $tailscale_installed ]; then
|
||||
# if tailscale is installed
|
||||
#
|
||||
# https://www.reddit.com/r/Tailscale/comments/18dirro/is_there_a_way_i_can_tell_which_exit_node_i_am/
|
||||
node=$(tailscale status | grep "; exit node")
|
||||
if [[ -z $node ]] || [[ "$node" == 'null' ]]; then
|
||||
# no tailscale exit node, no output, since trafic isnt actually rerouted
|
||||
echo ""
|
||||
else
|
||||
exitnode=$(tailscale status | grep "; exit node" | awk '{print $2}')
|
||||
|
||||
if $verbose; then
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" " ")
|
||||
echo "$vpn_label$exitnode"
|
||||
else
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" "Tailscale")
|
||||
echo "$vpn_label"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
|
||||
verbose=$(get_tmux_option "@dracula-network-vpn-verbose" false)
|
||||
|
||||
vpn="$(scutil --nc list | sed "s/\*//g" | grep Connected)"
|
||||
|
||||
is_not_tailscale=$(echo "$vpn" | grep -v Tailscale)
|
||||
|
||||
which -s tailscale > /dev/null
|
||||
tailscale_installed=$?
|
||||
|
||||
if [ -z "$vpn" ]; then
|
||||
echo ""
|
||||
|
||||
elif [ $tailscale_installed ] && [ -z "$is_not_tailscale" ]; then
|
||||
# if tailscale is installed and no other vpn is connected. this is because tailscale will
|
||||
# always show as connected for some reason.
|
||||
#
|
||||
# https://www.reddit.com/r/Tailscale/comments/18dirro/is_there_a_way_i_can_tell_which_exit_node_i_am/
|
||||
node=$(tailscale status | grep "; exit node")
|
||||
if [[ -z $node ]] || [[ "$node" == 'null' ]]; then
|
||||
# no tailscale exit node, no output, since trafic isnt actually rerouted
|
||||
echo ""
|
||||
else
|
||||
exitnode=$(tailscale status | grep "; exit node" | cut -w -f 2)
|
||||
|
||||
if $verbose; then
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" " ")
|
||||
echo "$vpn_label$exitnode"
|
||||
else
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" "Tailscale")
|
||||
echo "$vpn_label"
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
if $verbose; then
|
||||
vpn_name=$(echo $is_not_tailscale | sed "s/.*\"\(.*\)\".*/\1/g")
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" " ")
|
||||
echo "$vpn_label$vpn_name"
|
||||
else
|
||||
vpn_label=$(get_tmux_option "@dracula-network-vpn-label" "VPN")
|
||||
echo "$vpn_label"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
CYGWIN* | MINGW32* | MSYS* | MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
echo $(vpn_function)
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
||||
68
data/tmux/plugins/tmux/scripts/playerctl.sh
Executable file
68
data/tmux/plugins/tmux/scripts/playerctl.sh
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
function slice_loop() {
|
||||
local str="$1"
|
||||
local start="$2"
|
||||
local how_many="$3"
|
||||
local len=${#str}
|
||||
|
||||
local result=""
|
||||
|
||||
for ((i = 0; i < how_many; i++)); do
|
||||
local index=$(((start + i) % len))
|
||||
local char="${str:index:1}"
|
||||
result="$result$char"
|
||||
done
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
main() {
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
|
||||
if ! command -v playerctl &>/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FORMAT=$(get_tmux_option "@dracula-playerctl-format" "Now playing: {{ artist }} - {{ album }} - {{ title }}")
|
||||
playerctl_playback=$(playerctl metadata --format "${FORMAT}")
|
||||
playerctl_playback="${playerctl_playback} "
|
||||
|
||||
# Adjust width of string
|
||||
terminal_width=25
|
||||
|
||||
# Initial start point for scrolling
|
||||
start=0
|
||||
len=${#playerctl_playback}
|
||||
|
||||
# previously we have appended a space to playerctl_playback
|
||||
# if there is no player, len sees only one space
|
||||
# exit the script and output nothing if there is just that space
|
||||
if [[ $len == 1 ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
scrolling_text=""
|
||||
|
||||
for ((start = 0; start <= len; start++)); do
|
||||
scrolling_text=$(slice_loop "$playerctl_playback" "$start" "$terminal_width")
|
||||
echo -ne "\r"
|
||||
echo "$scrolling_text "
|
||||
echo -ne "\r"
|
||||
|
||||
sleep 0.08
|
||||
done
|
||||
|
||||
echo -ne "\r"
|
||||
echo "$scrolling_text "
|
||||
echo -ne "\r"
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
88
data/tmux/plugins/tmux/scripts/ram_info.sh
Executable file
88
data/tmux/plugins/tmux/scripts/ram_info.sh
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
get_ratio()
|
||||
{
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
usage="$(free -h | awk 'NR==2 {print $3}')"
|
||||
total="$(free -h | awk 'NR==2 {print $2}')"
|
||||
formated="${usage}/${total}"
|
||||
|
||||
echo "${formated//i/B}"
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
# Get used memory blocks with vm_stat, multiply by page size to get size in bytes, then convert to MiB
|
||||
used_mem=$(vm_stat | grep ' active\|wired\|compressor\|speculative' | sed 's/[^0-9]//g' | paste -sd ' ' - | awk -v pagesize=$(pagesize) '{printf "%d\n", ($1+$2+$3+$5) * pagesize / 1048576}')
|
||||
# System Profiler performs an activation lock check, which can result in
|
||||
# time outs or a lagged response. (~10 seconds)
|
||||
# total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}')
|
||||
total_mem=$(sysctl -n hw.memsize | awk '{print $0/1024/1024/1024 " GB"}')
|
||||
if ((used_mem < 1024 )); then
|
||||
echo "${used_mem}MB/$total_mem"
|
||||
else
|
||||
memory=$((used_mem/1024))
|
||||
echo "${memory}GB/$total_mem"
|
||||
fi
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
# Looked at the code from neofetch
|
||||
hw_pagesize="$(sysctl -n hw.pagesize)"
|
||||
mem_inactive="$(($(sysctl -n vm.stats.vm.v_inactive_count) * hw_pagesize))"
|
||||
mem_unused="$(($(sysctl -n vm.stats.vm.v_free_count) * hw_pagesize))"
|
||||
mem_cache="$(($(sysctl -n vm.stats.vm.v_cache_count) * hw_pagesize))"
|
||||
|
||||
free_mem=$(((mem_inactive + mem_unused + mem_cache) / 1024 / 1024))
|
||||
total_mem=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
||||
used_mem=$((total_mem - free_mem))
|
||||
echo $used_mem
|
||||
if ((used_mem < 1024 )); then
|
||||
echo "${used_mem}MB/$total_mem"
|
||||
else
|
||||
memory=$((used_mem/1024))
|
||||
echo "${memory}GB/$total_mem"
|
||||
fi
|
||||
;;
|
||||
|
||||
OpenBSD)
|
||||
# vmstat -s | grep "pages managed" | sed -ne 's/^ *\([0-9]*\).*$/\1/p'
|
||||
# Looked at the code from neofetch
|
||||
hw_pagesize="$(pagesize)"
|
||||
used_mem=$(( (
|
||||
$(vmstat -s | grep "pages active$" | sed -ne 's/^ *\([0-9]*\).*$/\1/p') +
|
||||
$(vmstat -s | grep "pages inactive$" | sed -ne 's/^ *\([0-9]*\).*$/\1/p') +
|
||||
$(vmstat -s | grep "pages wired$" | sed -ne 's/^ *\([0-9]*\).*$/\1/p') +
|
||||
$(vmstat -s | grep "pages zeroed$" | sed -ne 's/^ *\([0-9]*\).*$/\1/p') +
|
||||
0) * hw_pagesize / 1024 / 1024 ))
|
||||
total_mem=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
||||
#used_mem=$((total_mem - free_mem))
|
||||
total_mem=$(($total_mem/1024))
|
||||
if (( $used_mem < 1024 )); then
|
||||
echo $used_mem\M\B/$total_mem\G\B
|
||||
else
|
||||
memory=$(($used_mem/1024))
|
||||
echo $memory\G\B/$total_mem\G\B
|
||||
fi
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
ram_label=$(get_tmux_option "@dracula-ram-usage-label" "RAM")
|
||||
ram_ratio=$(get_ratio)
|
||||
echo "$ram_label $ram_ratio"
|
||||
}
|
||||
|
||||
#run main driver
|
||||
main
|
||||
35
data/tmux/plugins/tmux/scripts/spotify-tui.sh
Executable file
35
data/tmux/plugins/tmux/scripts/spotify-tui.sh
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
|
||||
if ! command -v spt &> /dev/null
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(spt list --devices)" = "No devices available" ]
|
||||
then
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
FORMAT=$(get_tmux_option "@dracula-spotify-tui-format" "%f %s %t - %a")
|
||||
spotify_playback=$(spt playback -f "${FORMAT}")
|
||||
max_len=$(get_tmux_option "@dracula-spotify-tui-max-len" 0)
|
||||
if [[ $max_len -ne 0 ]] ; then
|
||||
echo ${spotify_playback} | head -c $max_len
|
||||
else
|
||||
echo ${spotify_playback}
|
||||
fi
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
120
data/tmux/plugins/tmux/scripts/spr.sh
Executable file
120
data/tmux/plugins/tmux/scripts/spr.sh
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$current_dir/utils.sh"
|
||||
|
||||
|
||||
trackStatus() {
|
||||
local pause_icon="$1" play_icon="$2"
|
||||
local track_info playback status track_result
|
||||
|
||||
playback=$(spotify_player get key playback)
|
||||
|
||||
|
||||
status=$(echo "$playback" | jq -r '.["is_playing"]')
|
||||
track_info=$(echo "$playback" | jq -r '.item | "\(.artists | map(.name) | join(", ")) - \(.name)"')
|
||||
track_result=""
|
||||
|
||||
if [[ $status == "true" ]]; then
|
||||
track_result+=$play_icon
|
||||
track_result+=$track_info
|
||||
else
|
||||
track_result+=$pause_icon
|
||||
track_result+=$track_info
|
||||
fi
|
||||
|
||||
case "$status" in
|
||||
"null") echo "spotify not running" ;;
|
||||
*) echo "$track_result" ;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
function sliceTrack()
|
||||
{
|
||||
local str="$1"
|
||||
local std="$2"
|
||||
local len=${#str}
|
||||
|
||||
local result=""
|
||||
|
||||
if [[ $len > $std ]]; then
|
||||
result="${str:0:$std}"
|
||||
result+="..."
|
||||
else
|
||||
result=$str
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
|
||||
function sprRemoteControl() {
|
||||
local toggle_button="$1"
|
||||
local back_button="$2"
|
||||
local next_button="$3"
|
||||
|
||||
local toggle="spotify_player playback play-pause > /dev/null 2>&1"
|
||||
local back="spotify_player playback previous > /dev/null 2>&1"
|
||||
local next="spotify_player playback next > /dev/null 2>&1"
|
||||
|
||||
|
||||
tmux unbind-key "$toggle_button" 2>/dev/null
|
||||
tmux unbind-key "$back_button" 2>/dev/null
|
||||
tmux unbind-key "$next_button" 2>/dev/null
|
||||
|
||||
tmux bind-key "$toggle_button" run-shell "$toggle"
|
||||
tmux bind-key "$back_button" run-shell "$back"
|
||||
tmux bind-key "$next_button" run-shell "$next"
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
# save buffer to prevent lag
|
||||
local cache_file="/tmp/tmux_spr_cache"
|
||||
|
||||
RATE="$(get_tmux_option "@dracula-refresh-rate" 5)"
|
||||
|
||||
MAX_LENGTH="$(get_tmux_option "@dracula-spr-length" 25)"
|
||||
|
||||
# Remote Control checker
|
||||
SPR_REMOTE_ACCESS="$(get_tmux_option "@dracula-spr-remote" "false")"
|
||||
|
||||
PLAY_ICON=$(get_tmux_option "@dracula-spr-play-icon" "♪ ")
|
||||
PAUSE_ICON=$(get_tmux_option "@dracula-spr-pause-icon" "❚❚ ")
|
||||
|
||||
|
||||
if ! command -v spotify_player &> /dev/null
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remote Access
|
||||
if [[ "$SPR_REMOTE_ACCESS" == "true" ]]; then
|
||||
PLAY_PAUSE_BUTTON=$(get_tmux_option "@dracula-spr-remote-play-pause" "P")
|
||||
BACK_BUTTON=$(get_tmux_option "@dracula-spr-remote-back" "R")
|
||||
NEXT_BUTTON=$(get_tmux_option "@dracula-spr-remote-next" "N")
|
||||
sprRemoteControl "$PLAY_PAUSE_BUTTON" "$BACK_BUTTON" "$NEXT_BUTTON"
|
||||
else
|
||||
tmux set -g @dracula-spr-remote-play-pause ""
|
||||
tmux set -g @dracula-spr-remote-back ""
|
||||
tmux set -g @dracula-spr-remote-next ""
|
||||
tmux unbind-key "$PLAY_PAUSE_BUTTON" 2>/dev/null
|
||||
tmux unbind-key "$BACK_BUTTON" 2>/dev/null
|
||||
tmux unbind-key "$NEXT_BUTTON" 2>/dev/null
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f "$cache_file" ] || [ $(($(date +%s) - $(stat -c%Y "$cache_file" 2>/dev/null || stat -f%m "$cache_file"))) -ge "$RATE" ]; then
|
||||
local full_track
|
||||
full_track=$(trackStatus "$PAUSE_ICON" "$PLAY_ICON")
|
||||
sliceTrack "$full_track" "$MAX_LENGTH" > "$cache_file"
|
||||
fi
|
||||
|
||||
cat "$cache_file"
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
127
data/tmux/plugins/tmux/scripts/ssh_session.sh
Executable file
127
data/tmux/plugins/tmux/scripts/ssh_session.sh
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
show_ssh_session_port=$1
|
||||
|
||||
parse_ssh_port() {
|
||||
# Get port from connection
|
||||
local port=$(echo $1|grep -Eo '\-p\s*([0-9]+)'|sed 's/-p\s*//')
|
||||
|
||||
if [ -z $port ]; then
|
||||
local port=22
|
||||
fi
|
||||
|
||||
echo $port
|
||||
}
|
||||
|
||||
parse_ssh_config() {
|
||||
for ssh_config in `awk '
|
||||
$1 == "Host" {
|
||||
gsub("\\\\.", "\\\\.", $2);
|
||||
gsub("\\\\*", ".*", $2);
|
||||
host = $2;
|
||||
next;
|
||||
}
|
||||
$1 == "User" {
|
||||
$1 = "";
|
||||
sub( /^[[:space:]]*/, "" );
|
||||
printf "%s|%s\n", host, $0;
|
||||
}' $1`; do
|
||||
local host_regex=${ssh_config%|*}
|
||||
local host_user=${ssh_config#*|}
|
||||
if [ "$2" == "$host_regex" ]; then
|
||||
ssh_user_found=$host_user
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo $ssh_user_found
|
||||
}
|
||||
|
||||
get_ssh_user() {
|
||||
# Search SSH User in user local file if available
|
||||
if [ -f ~/.ssh/config ]; then
|
||||
ssh_user=$(parse_ssh_config ~/.ssh/config $1)
|
||||
fi
|
||||
|
||||
# If SSH User not found, search in global config file
|
||||
if [ -z $ssh_user ]; then
|
||||
ssh_user=$(parse_ssh_config /etc/ssh/ssh_config $1)
|
||||
fi
|
||||
|
||||
#If SSH User not found in any config file, return current user
|
||||
if [ -z $ssh_user ]; then
|
||||
ssh_user=$(whoami)
|
||||
fi
|
||||
|
||||
echo $ssh_user
|
||||
}
|
||||
|
||||
get_remote_info() {
|
||||
local command=$1
|
||||
|
||||
# First get the current pane command pid to get the full command with arguments
|
||||
local cmd=$({ pgrep -flaP `tmux display-message -p "#{pane_pid}"` ; ps -o command -p `tmux display-message -p "#{pane_pid}"` ; } | xargs -I{} echo {} | grep ssh | sed -E 's/^[0-9]*[[:blank:]]*ssh //')
|
||||
local port=$(parse_ssh_port "$cmd")
|
||||
|
||||
local cmd=$(echo $cmd|sed 's/\-p\s*'"$port"'//g')
|
||||
local user=$(echo $cmd | awk '{print $NF}'|cut -f1 -d@)
|
||||
local host=$(echo $cmd | awk '{print $NF}'|cut -f2 -d@)
|
||||
|
||||
if [ $user == $host ]; then
|
||||
local user=$(get_ssh_user $host)
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
"whoami")
|
||||
echo $user
|
||||
;;
|
||||
"hostname")
|
||||
echo $host
|
||||
;;
|
||||
"port")
|
||||
echo $port
|
||||
;;
|
||||
*)
|
||||
echo "$user@$host:$port"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_info() {
|
||||
# If command is ssh get info from remote
|
||||
if $(ssh_connected); then
|
||||
echo $(get_remote_info $1)
|
||||
else
|
||||
echo $($1)
|
||||
fi
|
||||
}
|
||||
|
||||
ssh_connected() {
|
||||
# Get current pane command
|
||||
local cmd=$(tmux display-message -p "#{pane_current_command}")
|
||||
|
||||
[ $cmd = "ssh" ] || [ $cmd = "sshpass" ]
|
||||
}
|
||||
|
||||
main() {
|
||||
hostname=$(get_info hostname)
|
||||
user=$(get_info whoami)
|
||||
|
||||
# Only show port info if ssh session connected (no localhost) and option enabled
|
||||
if $(get_tmux_option "@dracula-show-ssh-only-when-connected" false) && ! $(ssh_connected); then
|
||||
echo ""
|
||||
elif $(ssh_connected) && [ "$show_ssh_session_port" == "true" ] ; then
|
||||
port=$(get_info port)
|
||||
echo $user@$hostname:$port
|
||||
else
|
||||
echo $user@$hostname
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
||||
42
data/tmux/plugins/tmux/scripts/synchronize_panes.sh
Executable file
42
data/tmux/plugins/tmux/scripts/synchronize_panes.sh
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
label=$1
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
get_synchronize_panes_status() {
|
||||
current_synchronize_panes_status=$(get_tmux_window_option "synchronize-panes" "off")
|
||||
echo $current_synchronize_panes_status
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
|
||||
# Use the @dracula-synchronize-panes-refresh-rate plugin variable to override it.
|
||||
RATE_OVERRIDE=$(get_tmux_option "@dracula-synchronize-panes-refresh-rate" "")
|
||||
if [[ -n "$RATE_OVERRIDE" ]]; then
|
||||
RATE="$RATE_OVERRIDE"
|
||||
fi
|
||||
|
||||
synchronize_panes_auto_hide=$(get_tmux_option "@dracula-synchronize-panes-auto-hide" "false")
|
||||
synchronize_panes_status=$(get_synchronize_panes_status)
|
||||
synchronize_panes_label=$label
|
||||
|
||||
if [[ "$synchronize_panes_auto_hide" == 'true' ]]; then
|
||||
if [[ "$synchronize_panes_status" == 'on' ]]; then
|
||||
echo "$synchronize_panes_label"
|
||||
fi
|
||||
else
|
||||
echo "$synchronize_panes_label $synchronize_panes_status"
|
||||
fi
|
||||
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
||||
22
data/tmux/plugins/tmux/scripts/sys_temp.sh
Executable file
22
data/tmux/plugins/tmux/scripts/sys_temp.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
get_temp() {
|
||||
if grep -q "Raspberry" /proc/device-tree/model 2>/dev/null; then
|
||||
# It's a Raspberry pi
|
||||
echo "$(vcgencmd measure_temp | sed 's/temp=//')"
|
||||
else
|
||||
echo "$(sensors | grep 'Tctl' | awk '{print substr($2, 2)}')"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
echo "$(get_temp)"
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
||||
34
data/tmux/plugins/tmux/scripts/terraform.sh
Executable file
34
data/tmux/plugins/tmux/scripts/terraform.sh
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
tf_fork=$1
|
||||
tf_hide_status=$2
|
||||
label=$3
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
main() {
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
OUTPUT_STRING="N/A"
|
||||
terraform_dir="$(tmux display-message -p '#{pane_current_path}')/.terraform"
|
||||
if [ -d $terraform_dir ]; then
|
||||
current_workspace=$($tf_fork workspace show 2>/dev/null)
|
||||
OUTPUT_STRING="${current_workspace}"
|
||||
elif [ "$tf_hide_status" = "true" ]; then
|
||||
return
|
||||
fi
|
||||
if [ "$label" = "" ]
|
||||
then
|
||||
echo "⚙️ ${OUTPUT_STRING}"
|
||||
else
|
||||
echo "⚙️ ${label} ${OUTPUT_STRING}"
|
||||
fi
|
||||
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
||||
120
data/tmux/plugins/tmux/scripts/tmux_ram_info.sh
Executable file
120
data/tmux/plugins/tmux/scripts/tmux_ram_info.sh
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source "$current_dir/utils.sh"
|
||||
|
||||
get_cpids_linux() {
|
||||
local ppid="$1"
|
||||
local cpids
|
||||
local cpid
|
||||
echo "$ppid"
|
||||
cpids="$(pgrep -P "$ppid")"
|
||||
for cpid in $cpids; do
|
||||
get_cpids_linux "$cpid"
|
||||
done
|
||||
}
|
||||
|
||||
get_cpids_unix() {
|
||||
local ppid="$1"
|
||||
local cpids
|
||||
local cpid
|
||||
echo "$ppid"
|
||||
cpids="$(pgrep -aP "$ppid")"
|
||||
for cpid in $cpids; do
|
||||
get_cpids_unix "$cpid"
|
||||
done
|
||||
}
|
||||
|
||||
kb_to_mb() {
|
||||
if [ $# == 0 ]; then
|
||||
read -r num
|
||||
else
|
||||
num="$1"
|
||||
fi
|
||||
bc <<< "scale=3;$num/1024"
|
||||
}
|
||||
|
||||
kb_to_gb() {
|
||||
if [ $# == 0 ]; then
|
||||
read -r num
|
||||
else
|
||||
num="$1"
|
||||
fi
|
||||
bc <<< "scale=6;$num/1048576"
|
||||
}
|
||||
|
||||
round() {
|
||||
if [ $# == 1 ]; then
|
||||
read -r num
|
||||
scale="$1"
|
||||
elif [ $# == 2 ]; then
|
||||
num="$1"
|
||||
scale="$2"
|
||||
fi
|
||||
printf "%.${scale}f" "${num}"
|
||||
}
|
||||
|
||||
get_tmux_ram_usage()
|
||||
{
|
||||
local pid
|
||||
local pids
|
||||
local total_mem_kb=0
|
||||
local total_mem_mb=0
|
||||
local total_mem_gb=0
|
||||
pid="$(tmux display-message -pF '#{pid}')"
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
if command -v pstree > /dev/null; then
|
||||
pids="$(pstree -Tlp "$pid" | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')"
|
||||
else
|
||||
pids="$(get_cpids_linux "$pid" | tr '\n' ',')"
|
||||
fi
|
||||
total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ | bc)"
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
if command -v pstree > /dev/null; then
|
||||
pids="$(pstree -w "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')"
|
||||
else
|
||||
pids="$(get_cpids_unix "$pid" | tr '\n' ',')"
|
||||
fi
|
||||
total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ - | bc)"
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
# TODO check FreeBSD compatibility
|
||||
if command -v pstree > /dev/null; then
|
||||
pids="$(pstree -lp "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')"
|
||||
else
|
||||
pids="$(get_cpids_unix "$pid" | tr '\n' ',')"
|
||||
fi
|
||||
total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ - | bc)"
|
||||
;;
|
||||
|
||||
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
total_mem_mb=$(kb_to_mb "$total_mem_kb" | round 0)
|
||||
total_mem_gb=$(kb_to_gb "$total_mem_kb" | round 0)
|
||||
|
||||
if (( total_mem_gb > 0)); then
|
||||
echo "${total_mem_gb}GB"
|
||||
elif (( total_mem_mb > 0 )); then
|
||||
echo "${total_mem_mb}MB"
|
||||
else
|
||||
echo "${total_mem_kb}kB"
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
ram_label=$(get_tmux_option "@dracula-tmux-ram-usage-label" "MEM")
|
||||
ram_usage=$(get_tmux_ram_usage)
|
||||
echo "$ram_label $ram_usage"
|
||||
}
|
||||
|
||||
#run main driver
|
||||
main
|
||||
15
data/tmux/plugins/tmux/scripts/uptime.sh
Executable file
15
data/tmux/plugins/tmux/scripts/uptime.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
main()
|
||||
{
|
||||
uptime_label=$(get_tmux_option "@dracula-uptime-label" "UP")
|
||||
uptime=$(uptime | awk -F' up ' '{ split($2,a,","); printf "%s", a[1] }')
|
||||
echo "$uptime_label $uptime"
|
||||
}
|
||||
|
||||
main
|
||||
36
data/tmux/plugins/tmux/scripts/utils.sh
Normal file
36
data/tmux/plugins/tmux/scripts/utils.sh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
get_tmux_window_option() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value="$(tmux show-window-options -v "$option")"
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
echo "$option_value"
|
||||
fi
|
||||
}
|
||||
|
||||
# normalize the percentage string to always have a length of 5
|
||||
normalize_percent_len() {
|
||||
# the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%"
|
||||
max_len=5
|
||||
percent_len=${#1}
|
||||
let diff_len=$max_len-$percent_len
|
||||
# if the diff_len is even, left will have 1 more space than right
|
||||
let left_spaces=($diff_len+1)/2
|
||||
let right_spaces=($diff_len)/2
|
||||
printf "%${left_spaces}s%s%${right_spaces}s\n" "" $1 ""
|
||||
}
|
||||
|
||||
140
data/tmux/plugins/tmux/scripts/weather.sh
Executable file
140
data/tmux/plugins/tmux/scripts/weather.sh
Executable file
|
|
@ -0,0 +1,140 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
API_URL="https://wttr.in"
|
||||
DELIM=":"
|
||||
|
||||
# emulate timeout command from bash - timeout is not available by default on OSX
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
function timeout() {
|
||||
local _duration
|
||||
_duration="${1:-1}"
|
||||
command -p perl -e 'alarm shift; exec @ARGV' "$_duration" "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# Fetch weather information from remote API
|
||||
# Globals:
|
||||
# API_URL
|
||||
# DELIM
|
||||
# Arguments:
|
||||
# show fahrenheit, either "true" or "false"
|
||||
# optional fixed location to query weather data about
|
||||
function fetch_weather_information() {
|
||||
local _show_fahrenheit _location _unit
|
||||
_show_fahrenheit="$1"
|
||||
_location="$2"
|
||||
|
||||
if "$_show_fahrenheit"; then
|
||||
_unit="u"
|
||||
else
|
||||
_unit="m"
|
||||
fi
|
||||
|
||||
# If the user provies a "fixed location", `@dracula-fixed-location`, that the
|
||||
# API does not recognize, the API may suggest a users actual geoip GPS
|
||||
# location in the response body. This can lead to user PI leak.
|
||||
# Drop response body when status code >= 400 and return nonzero by passing the
|
||||
# `--fail` flag. Execute curl last to allow the consumer to leverage the
|
||||
# return code. Pass `--show-error` and redirect stderr for the consumer.
|
||||
command -p curl -L --silent --fail --show-error \
|
||||
"${API_URL}/${_location// /%20}?format=%C${DELIM}%t${DELIM}%l&${_unit}" 2>&1
|
||||
}
|
||||
|
||||
# Format raw weather information from API
|
||||
# Globals:
|
||||
# DELIM
|
||||
# Arguments:
|
||||
# The raw weather data as returned by "fetch_weather_information()"
|
||||
# show location, either "true" or "false"
|
||||
function format_weather_info() {
|
||||
local _raw _show_location
|
||||
_raw="$1" # e.g. "Rain:+63°F:Houston, Texas, United States"
|
||||
_show_location="$2"
|
||||
|
||||
local _weather _temp _location
|
||||
_weather="${_raw%%"${DELIM}"*}" # slice temp and location to get weather
|
||||
_weather=$(printf '%s' "$_weather" | tr '[:upper:]' '[:lower:]') # lowercase weather, OSX’s bash3.2 does not support ${v,,}
|
||||
_temp="${_raw#*"${DELIM}"}" # slice weather to get temp and location
|
||||
_temp="${_temp%%"${DELIM}"*}" # slice location to get temp
|
||||
_temp="${_temp/+/}" # slice "+" from "+74°F"
|
||||
_location="${_raw##*"${DELIM}"}" # slice weather and temp to get location
|
||||
[ "${_location//[^,]/}" == ",," ] && _location="${_location%,*}" # slice country if it exists
|
||||
|
||||
case "$_weather" in
|
||||
'snow')
|
||||
_weather='❄'
|
||||
;;
|
||||
'rain' | 'shower')
|
||||
_weather='☂'
|
||||
;;
|
||||
'overcast' | 'cloud')
|
||||
_weather='☁'
|
||||
;;
|
||||
'na')
|
||||
_weather=''
|
||||
;;
|
||||
*)
|
||||
_weather='☀'
|
||||
;;
|
||||
esac
|
||||
|
||||
if "$_show_location"; then
|
||||
printf '%s %s %s' "$_weather" "$_temp" "$_location"
|
||||
else
|
||||
printf '%s %s' "$_weather" "$_temp"
|
||||
fi
|
||||
}
|
||||
|
||||
# Display weather, temperature, and location
|
||||
# Globals
|
||||
# none
|
||||
# Arguments
|
||||
# show fahrenheit, either "true" (default) or "false"
|
||||
# show location, either "true" (default) or "false"
|
||||
# optional fixed location to query data about, e.g. "Houston, Texas"
|
||||
# hide errors, either "true" or "false" (default)
|
||||
function main() {
|
||||
local _show_fahrenheit _show_location _location _hide_errors
|
||||
_show_fahrenheit="${1:-true}"
|
||||
_show_location="${2:-true}"
|
||||
_location="$3"
|
||||
_hide_errors="${4:-false}"
|
||||
|
||||
# process should be cancelled when session is killed
|
||||
if ! timeout 1 bash -c "</dev/tcp/wttr.in/443"; then
|
||||
if "$_hide_errors"; then
|
||||
printf ''
|
||||
else
|
||||
printf 'Weather Unavailable\n'
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
# BashFAQ/002: assignment of substitution does not effect status code.
|
||||
local _resp
|
||||
if ! _resp=$(fetch_weather_information "$_show_fahrenheit" "$_location"); then
|
||||
|
||||
if "$_hide_errors"; then
|
||||
printf ''
|
||||
return
|
||||
fi
|
||||
|
||||
# e.g. "curl: (22) The requested URL returned error: 404"
|
||||
case "${_resp##* }" in
|
||||
404)
|
||||
printf 'Unknown Location\n'
|
||||
;;
|
||||
*)
|
||||
printf 'Weather Unavailable\n'
|
||||
;;
|
||||
esac
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
format_weather_info "$_resp" "$_show_location"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
38
data/tmux/plugins/tmux/scripts/weather_wrapper.sh
Executable file
38
data/tmux/plugins/tmux/scripts/weather_wrapper.sh
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
DATAFILE="/tmp/.dracula-tmux-weather-data"
|
||||
LAST_EXEC_FILE="/tmp/.dracula-tmux-weather-last-exec"
|
||||
INTERVAL=1200
|
||||
|
||||
# Call weather script on interval to prevent exhausting remote API
|
||||
# Globals:
|
||||
# DATAFILE
|
||||
# LAST_EXEC_FILE
|
||||
# INTERVAL
|
||||
# Arguments:
|
||||
# show fahrenheit, either "true" (default) or "false"
|
||||
# show location, either "true" (default) or "false"
|
||||
# optional fixed location to query data about, e.g. "Houston, Texas"
|
||||
# hide errors, either "true" or "false" (default)
|
||||
function main() {
|
||||
local _show_fahrenheit _show_location _hide_errors _location _current_dir _last _now
|
||||
_show_fahrenheit="$1"
|
||||
_show_location="$2"
|
||||
_location="$3"
|
||||
_hide_errors="$4"
|
||||
_current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
_last=$(cat "$LAST_EXEC_FILE" 2>/dev/null || echo 0)
|
||||
_now=$(date +%s)
|
||||
|
||||
if (((_now - _last) > INTERVAL)); then
|
||||
# Run weather script here
|
||||
"${_current_dir}/weather.sh" "$_show_fahrenheit" "$_show_location" "$_location" "$_hide_errors" >"${DATAFILE}"
|
||||
printf '%s' "$_now" >"${LAST_EXEC_FILE}"
|
||||
fi
|
||||
|
||||
cat "${DATAFILE}"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
17
data/tmux/tmux.conf
Normal file
17
data/tmux/tmux.conf
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
unbind C-b
|
||||
set-option -g prefix C-a
|
||||
bind-key C-a send-prefix
|
||||
set-option -g history-limit 100000
|
||||
|
||||
set -g mouse on
|
||||
set -g @plugin 'dracula/tmux'
|
||||
|
||||
set -g @dracula-plugins "cwd git"
|
||||
|
||||
set -g @dracula-show-left-icon "#S"
|
||||
set -g @dracula-git-disable-status true
|
||||
|
||||
set -g pane-border-lines heavy
|
||||
|
||||
# tpm - keep at bottom
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
Loading…
Add table
Add a link
Reference in a new issue