urlview: finalize
This commit is contained in:
parent
221ae40e4f
commit
2e71677213
@ -206,11 +206,13 @@ in {
|
|||||||
set-option -g default-terminal "screen-256color"
|
set-option -g default-terminal "screen-256color"
|
||||||
set-option -sa terminal-features ',xterm-256color:RGB'
|
set-option -sa terminal-features ',xterm-256color:RGB'
|
||||||
|
|
||||||
run-shell ${(pkgs.substituteAll {
|
run-shell ${pkgs.writeShellScript "urlview"
|
||||||
|
(builtins.readFile
|
||||||
|
(pkgs.substituteAll {
|
||||||
src = ./urlview.tmux;
|
src = ./urlview.tmux;
|
||||||
extract_url = pkgs.extract_url;
|
extract_url = pkgs.extract_url;
|
||||||
})
|
})
|
||||||
.outPath}
|
.outPath)}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly key="$(get_tmux_option "@urlview-key" "u")"
|
|
||||||
|
|
||||||
tmux bind-key "$key" capture-pane -J \\\; \
|
|
||||||
save-buffer "${TMPDIR:-/tmp}/tmux-buffer" \\\; \
|
|
||||||
delete-buffer \\\; \
|
|
||||||
split-window -l 10 "@extract_url@/bin/extract_url" '${TMPDIR:-/tmp}/tmux-buffer'"
|
|
31
shared/home/urlview.tmux
Normal file → Executable file
31
shared/home/urlview.tmux
Normal file → Executable file
@ -1,32 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
get_tmux_option() {
|
get_tmux_option() {
|
||||||
local option=$1
|
local option=$1
|
||||||
local default_value=$2
|
local default_value=$2
|
||||||
local option_value=$(tmux show-option -gqv "$option")
|
local option_value
|
||||||
if [ -z $option_value ]; then
|
option_value=$(tmux show-option -gqv "$option")
|
||||||
echo $default_value
|
if [ -z "$option_value" ]; then
|
||||||
|
echo "$default_value"
|
||||||
else
|
else
|
||||||
echo $option_value
|
echo "$option_value"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
find_executable() {
|
tmux bind-key "$(get_tmux_option "@urlview-key" "u")" capture-pane -J \\\; \
|
||||||
if type urlview >/dev/null 2>&1; then
|
|
||||||
echo "urlview"
|
|
||||||
elif type extract_url >/dev/null 2>&1; then
|
|
||||||
echo "extract_url"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly key="$(get_tmux_option "@urlview-key" "u")"
|
|
||||||
readonly cmd="$(find_executable)"
|
|
||||||
|
|
||||||
if [ -z "$cmd" ]; then
|
|
||||||
tmux display-message "Failed to load tmux-urlview: neither urlview nor extract_url were found on the PATH"
|
|
||||||
else
|
|
||||||
tmux bind-key "$key" capture-pane -J \\\; \
|
|
||||||
save-buffer "${TMPDIR:-/tmp}/tmux-buffer" \\\; \
|
save-buffer "${TMPDIR:-/tmp}/tmux-buffer" \\\; \
|
||||||
delete-buffer \\\; \
|
delete-buffer \\\; \
|
||||||
split-window -l 10 "$cmd '${TMPDIR:-/tmp}/tmux-buffer'"
|
split-window -l 10 "@extract_url@/bin/extract_url '${TMPDIR:-/tmp}/tmux-buffer'"
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user