mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-11 15:02:16 -04:00
tmux: move plugins to config
This commit is contained in:
parent
36249eb571
commit
3b5aebcd93
122 changed files with 4210 additions and 2 deletions
46
dot_config/tmux/plugins/tmux-session-wizard/src/helpers.sh
Normal file
46
dot_config/tmux/plugins/tmux-session-wizard/src/helpers.sh
Normal file
|
@ -0,0 +1,46 @@
|
|||
_normalize() {
|
||||
cat | tr ' .:' '-' | tr '[:upper:]' '[:lower:]'
|
||||
}
|
||||
|
||||
# helper functions
|
||||
get_tmux_option() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
local option_value
|
||||
option_value=$(tmux show-option -gqv "$option")
|
||||
if [ -z "$option_value" ]; then
|
||||
echo "$default_value"
|
||||
else
|
||||
echo "$option_value"
|
||||
fi
|
||||
}
|
||||
|
||||
session_name() {
|
||||
if [ "$1" = "--directory" ]; then
|
||||
shift
|
||||
basename "$@" | _normalize
|
||||
elif [ "$1" = "--full-path" ]; then
|
||||
shift
|
||||
echo "$@" | _normalize | sed 's/\/$//'
|
||||
elif [ "$1" = "--short-path" ]; then
|
||||
shift
|
||||
echo "$(echo "${@%/*}" | sed -r 's;/([^/]{1,2})[^/]*;/\1;g' | _normalize)/$(basename "$@" | _normalize)"
|
||||
else
|
||||
echo "Wrong argument, you can use --directory, --full-path or --short-path, got $1"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
HOME_REPLACER="" # default to a noop
|
||||
TILDE_REPLACER="" # default to a noop
|
||||
echo "$HOME" | grep -E "^[a-zA-Z0-9\-_/.@]+$" &>/dev/null # chars safe to use in sed
|
||||
HOME_SED_SAFE=$?
|
||||
if [ $HOME_SED_SAFE -eq 0 ]; then # $HOME should be safe to use in sed
|
||||
HOME_REPLACER="s|^$HOME|~|"
|
||||
TILDE_REPLACER="s|^~|$HOME|"
|
||||
fi
|
||||
|
||||
__fzfcmd() {
|
||||
[ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } &&
|
||||
echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue