Cleanup dotfiles
This commit is contained in:
48
dot_config/tmux/scripts/executable_get_git_hosting.sh
Normal file
48
dot_config/tmux/scripts/executable_get_git_hosting.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Use the provided path or default to the current directory.
|
||||
current_path="${1:-.}"
|
||||
cd "$current_path" 2>/dev/null || exit 1
|
||||
|
||||
# Check if we are inside a Git repository.
|
||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
# Get the URL of the 'origin' remote.
|
||||
remote_url="$(git config --get remote.origin.url)"
|
||||
|
||||
if [ -n "$remote_url" ]; then
|
||||
# We have a remote, so let's get the icon and domain.
|
||||
|
||||
# 1. Determine the icon based on the URL's content.
|
||||
icon=""
|
||||
if [[ $remote_url == *"github"* ]]; then
|
||||
icon=" "
|
||||
elif [[ $remote_url == *"gitlab"* ]]; then
|
||||
icon=" "
|
||||
elif [[ $remote_url == *"gitea"* ]]; then
|
||||
icon=" "
|
||||
else
|
||||
# Fallback icon for any other git remote (e.g., Bitbucket, Codeberg).
|
||||
icon=" "
|
||||
fi
|
||||
|
||||
# 2. Extract the domain from the remote URL.
|
||||
domain=""
|
||||
if [[ $remote_url =~ ^https?:// ]]; then
|
||||
# For HTTPS URLs (e.g., "https://github.com/user/repo.git")
|
||||
domain=$(echo "$remote_url" | sed -E 's#https?://([^/]+).*#\1#')
|
||||
elif [[ $remote_url =~ @ ]]; then
|
||||
# For SSH URLs (e.g., "git@github.com:user/repo.git")
|
||||
domain=$(echo "$remote_url" | sed -E 's/.*@([^:]+):.*/\1/')
|
||||
fi
|
||||
|
||||
# 3. Print the icon and the extracted domain.
|
||||
echo "$icon $domain"
|
||||
else
|
||||
# No remote is configured, so it's a local repository.
|
||||
echo " local"
|
||||
fi
|
||||
else
|
||||
# Not a git repository, so output nothing.
|
||||
echo ""
|
||||
fi
|
||||
|
||||
26
dot_config/tmux/scripts/executable_ssh_aware_directory.sh
Normal file
26
dot_config/tmux/scripts/executable_ssh_aware_directory.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Icons
|
||||
icon_local=" " # Your specified local icon
|
||||
icon_remote=" " # Your specified remote icon
|
||||
|
||||
current_cmd=$(tmux display-message -p '#{pane_current_command}')
|
||||
|
||||
if [[ "$current_cmd" == "ssh" ]]; then
|
||||
# Remote - get info from pane title
|
||||
pane_title_raw=$(tmux display-message -p '#{pane_title}')
|
||||
# Clean up: remove any spaces after the colon
|
||||
pane_title_cleaned=$(echo "$pane_title_raw" | sed 's/: /:/g')
|
||||
|
||||
# Output plain text: ICON user@host:directory (or ICON title if not parsable)
|
||||
echo "${icon_remote}${pane_title_cleaned:-remote}"
|
||||
else
|
||||
# Local - build the same format
|
||||
user_part="$(whoami)"
|
||||
host_part="$(hostname -s)"
|
||||
local_dir_raw=$(echo "$1" | sed "s|^$HOME|~|") # $1 is #{pane_current_path}
|
||||
|
||||
# Output plain text: ICON user@host:directory
|
||||
echo "${icon_local}${user_part}@${host_part}:${local_dir_raw}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user