qb: use long option name !

This commit is contained in:
gardouille 2024-09-18 11:46:19 +02:00
parent cc67a57ee5
commit e19ea4e5c4
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

34
qb
View File

@ -47,9 +47,9 @@ define_vars() { # {{{
## Variables to get Qutebrowser currents buffers
QUTEBROWSER_SESSION_FILE="/tmp/qutebrowser_buffers_zsbd"
QUTEBROWSER_SOCKET_FILE="${XDG_RUNTIME_DIR}/qutebrowser/ipc-$(echo -n "$USER" | md5sum | cut -d' ' -f1)"
QUTEBROWSER_SOCKET_FILE="${XDG_RUNTIME_DIR}/qutebrowser/ipc-$(echo -n "$USER" | md5sum | cut --delimiter=' ' --fields=1)"
QUTEBROWSER_GLOBAL_CONTENT="/tmp/qutebrowser_global_content"
rm -f -- "${QUTEBROWSER_GLOBAL_CONTENT}" ; touch "${QUTEBROWSER_GLOBAL_CONTENT}"
rm --force -- "${QUTEBROWSER_GLOBAL_CONTENT}" ; touch "${QUTEBROWSER_GLOBAL_CONTENT}"
## Variables to get Qutebrowser *marks from current user
QUTEBROWSER_QUICKMARK_FILE="${HOME}/.config/qutebrowser/quickmarks"
@ -58,7 +58,7 @@ define_vars() { # {{{
## Qutebrowser search engines from current user configuration
QUTEBROWSER_SEARCHENGINE_FILE="${HOME}/.config/qutebrowser/config.py"
QUTEBROWSER_SEARCHENGINE_LIST="/tmp/qutebrowser_searchengine.list"
rm -f -- "${QUTEBROWSER_SEARCHENGINE_LIST}" ; touch "${QUTEBROWSER_SEARCHENGINE_LIST}"
rm --force -- "${QUTEBROWSER_SEARCHENGINE_LIST}" ; touch "${QUTEBROWSER_SEARCHENGINE_LIST}"
## Default window pattern to search
QUTEBROWSER_WINDOW_TITLE="qutebrowser"
@ -89,7 +89,7 @@ is_proc_running() { # {{{
local_proc_pattern="${1}"
local_count_proc_pattern="$(pgrep -f -- "${local_proc_pattern}" | wc -l)"
local_count_proc_pattern="$(pgrep --full -- "${local_proc_pattern}" | wc --lines)"
case "${local_count_proc_pattern}" in
0 ) ## No procs related to this pattern are running
@ -159,7 +159,7 @@ Focus with wmctrl."
get_qutebrowser_buffers() { # {{{
## Clear previous buffers list
[ -f "${QUTEBROWSER_SESSION_FILE}" ] && rm -f -- "${QUTEBROWSER_SESSION_FILE}"
[ -f "${QUTEBROWSER_SESSION_FILE}" ] && rm --force -- "${QUTEBROWSER_SESSION_FILE}"
## Run save_buffers.py in Qutebrowser
echo '{"args":[":save-window-and-buffers"], "target_arg":"", "protocol_version":1}' |\
@ -202,9 +202,9 @@ get_qutebrowser_searchengine() { # {{{
if [ -f "${QUTEBROWSER_SEARCHENGINE_FILE}" ]; then
### Store search engine in global list (for display)
sed -n "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}"
sed --silent "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_GLOBAL_CONTENT}"
### And in specific list to verify is an engine was used
sed -n "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_SEARCHENGINE_LIST}"
sed --silent "s/c.url.searchengines\['\(.*\)'\] = '\(.*\)'$/\1 \2/p" "${QUTEBROWSER_SEARCHENGINE_FILE}" >> "${QUTEBROWSER_SEARCHENGINE_LIST}"
fi
if [ -s "${QUTEBROWSER_SEARCHENGINE_LIST}" ]; then
@ -260,12 +260,12 @@ Try to open ${RED}${url}${COLOR_DEBUG}"
# }}}
is_url_in_buffer() { # {{{
if grep -q -E -- "${url}" "${QUTEBROWSER_SESSION_FILE}"; then
if grep --quiet --extended-regexp -- "${url}" "${QUTEBROWSER_SESSION_FILE}"; then
debug_message "is_url_in_buffer \
A buffer is already opened with this URL."
return_is_url_in_buffer="0"
buffer_id=$(grep -E -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | cut -d" " -f1)
buffer_title=$(grep -E -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | sed "s;${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
buffer_id=$(grep --extended-regexp -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | cut --delimiter=" " --fields=1)
buffer_title=$(grep --extended-regexp -- "${url}" "${QUTEBROWSER_SESSION_FILE}" | sed "s;${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
switch_qutebrowser_buffer
else
@ -311,7 +311,7 @@ use_searchengine() { # {{{
return_use_searchengine="0"
## If the search engine can't be found
if ! grep --quiet -E "^${search_engine}" -- "${QUTEBROWSER_SEARCHENGINE_LIST}"; then
if ! grep --quiet --extended-regexp "^${search_engine}" -- "${QUTEBROWSER_SEARCHENGINE_LIST}"; then
### Set search engine to DEFAULT
search_engine="DEFAULT"
### Be sure to take the complete request
@ -321,7 +321,7 @@ use_searchengine() { # {{{
debug_message "use_searchengine \
Use ${RED}${search_engine}${COLOR_DEBUG} search engine."
search_url=$(grep -E "^${search_engine}" -- ${QUTEBROWSER_SEARCHENGINE_LIST} | cut --delimiter=" " --field=3)
search_url=$(grep --extended-regexp "^${search_engine}" -- ${QUTEBROWSER_SEARCHENGINE_LIST} | cut --delimiter=" " --field=3)
debug_message "use_searchengine \
Use URL ${RED}${search_url}${COLOR_DEBUG}"
@ -344,21 +344,21 @@ Try to manage ${RED}$(cat "${choice_temp_file}")${COLOR_DEBUG}."
case "${local_content}" in
bb*http* ) ## Classic bookmark
url=$(printf "%s" "${local_content}" | cut -d" " -f2)
url=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=2)
return_get_url="0"
debug_message "get_url \
URL from classic bookmark ${RED}${url}${COLOR_DEBUG}."
goto_url
;;
qq*http* ) ## Quickmark
url=$(printf "%s" "${local_content}" | cut -d" " -f3)
url=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=3)
return_get_url="0"
debug_message "get_url \
URL from quickmark ${RED}${url}${COLOR_DEBUG}."
goto_url
;;
ff* ) ## Buffer
buffer_id=$(printf "%s" "${local_content}" | cut -d" " -f2)
buffer_id=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=2)
buffer_title=$(printf "%s" "${local_content}" | sed "s;ff ${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
return_get_url="0"
debug_message "get_url \
@ -366,7 +366,7 @@ Buffer title from Qutebrowser: ${RED}${buffer_title}${COLOR_DEBUG}."
switch_qutebrowser_buffer
;;
* )
search_engine=$(printf "%s" "${local_content}" | cut -d" " -f1)
search_engine=$(printf "%s" "${local_content}" | cut --delimiter=" " --fields=1)
search_request=$(printf "%s" "${local_content}" | cut --complement --delimiter=" " --field=1)
debug_message "get_url \
Try to search the content."
@ -420,7 +420,7 @@ if [ ! "${NBARGS}" -eq "0" ]; then
manage_arg="0"
# Parse all options (start with a "-") one by one
while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do
while printf -- '%s' "${1}" | grep --quiet --extended-regexp -- "^-+"; do
case "${1}" in
-d|--debug ) ## Enable debug mode