mirror of
https://github.com/TECHNOFAB11/tmux2k.git
synced 2025-12-11 23:50:08 +01:00
docs: add current working dir plugin
This commit is contained in:
parent
4692ae758e
commit
52e3405b67
2 changed files with 38 additions and 37 deletions
|
|
@ -110,6 +110,7 @@ set -g @tmux2k-yellow '#f8c800' # change yellow color
|
|||
- `battery`: Show battery stats and percentage
|
||||
- `git`: Show Git branch and status information
|
||||
- `cpu`: Show CPU usage information
|
||||
- `cwd`: Show current working directory
|
||||
- `gpu`: Show GPU usage information
|
||||
- `ram`: Show RAM usage information
|
||||
- `network`: Show network status and statistics
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# return current working directory of tmux pane
|
||||
getPaneDir() {
|
||||
get_pane_dir() {
|
||||
nextone="false"
|
||||
ret=""
|
||||
for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); do
|
||||
|
|
@ -13,16 +13,16 @@ getPaneDir() {
|
|||
}
|
||||
|
||||
# truncate the path if it's longer than 30 characters
|
||||
truncatePath() {
|
||||
truncate_path() {
|
||||
local path="$1"
|
||||
local limit=30
|
||||
|
||||
if [ ${#path} -gt $limit ]; then
|
||||
# Split the path into an array by '/'
|
||||
IFS='/' read -r -a path_array <<< "$path"
|
||||
IFS='/' read -r -a path_array <<<"$path"
|
||||
truncated_path=""
|
||||
|
||||
for ((i=0; i<${#path_array[@]}-1; i++)); do
|
||||
for ((i = 0; i < ${#path_array[@]} - 1; i++)); do
|
||||
if [ ${#path_array[i]} -gt 1 ]; then
|
||||
truncated_path+="${path_array[i]:0:1}/"
|
||||
else
|
||||
|
|
@ -40,15 +40,15 @@ truncatePath() {
|
|||
}
|
||||
|
||||
main() {
|
||||
path=$(getPaneDir)
|
||||
path=$(get_pane_dir)
|
||||
|
||||
# change '/home/user' to '~'
|
||||
cwd="${path/"$HOME"/'~'}"
|
||||
|
||||
# Truncate path if it's too long
|
||||
truncated_cwd=$(truncatePath "$cwd")
|
||||
truncated_cwd=$(truncate_path "$cwd")
|
||||
|
||||
echo "$truncated_cwd"
|
||||
echo " $truncated_cwd"
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue