refactor: use __fish_palette in small utility functions (1/2)
37 duplicated declarations replaced by 8 calls. Output strings untouched; byte-identical across 29 harness cases.
This commit is contained in:
+1
-4
@@ -25,10 +25,7 @@
|
|||||||
function bkg --description 'Execute bkg'
|
function bkg --description 'Execute bkg'
|
||||||
# Check if a command was provided as an argument.
|
# Check if a command was provided as an argument.
|
||||||
if test -z "$argv[1]"
|
if test -z "$argv[1]"
|
||||||
set -l c_head (set_color --bold cyan)
|
__fish_palette
|
||||||
set -l c_cmd (set_color --bold)
|
|
||||||
set -l c_arg (set_color cyan)
|
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
echo "$c_head""Usage:$c_reset $c_cmd""bkg$c_reset $c_arg""<command> [arguments...]$c_reset"
|
echo "$c_head""Usage:$c_reset $c_cmd""bkg$c_reset $c_arg""<command> [arguments...]$c_reset"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,11 +25,7 @@
|
|||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# detach rsync -a ./data remote:/backup/
|
# detach rsync -a ./data remote:/backup/
|
||||||
function detach --description 'Execute detach'
|
function detach --description 'Execute detach'
|
||||||
set -l c_head (set_color --bold cyan)
|
__fish_palette
|
||||||
set -l c_cmd (set_color --bold)
|
|
||||||
set -l c_flag (set_color yellow)
|
|
||||||
set -l c_arg (set_color cyan)
|
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
|
|
||||||
set -l show_help 0
|
set -l show_help 0
|
||||||
set -l args
|
set -l args
|
||||||
|
|||||||
@@ -38,11 +38,7 @@ function dng2avif --description 'Convert DNG raw to 10-bit HDR AVIF'
|
|||||||
|
|
||||||
# Help Screen
|
# Help Screen
|
||||||
if set -q _flag_help; or test (count $argv) -eq 0 -a -z "$_flag_input"
|
if set -q _flag_help; or test (count $argv) -eq 0 -a -z "$_flag_input"
|
||||||
set -l c_head (set_color --bold cyan)
|
__fish_palette
|
||||||
set -l c_cmd (set_color --bold)
|
|
||||||
set -l c_flag (set_color yellow)
|
|
||||||
set -l c_dim (set_color brblack)
|
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
echo "$c_head""Usage:$c_reset $c_cmd""dng2avif$c_reset $c_flag""[options]$c_reset $c_dim""[input.dng]$c_reset"
|
echo "$c_head""Usage:$c_reset $c_cmd""dng2avif$c_reset $c_flag""[options]$c_reset $c_dim""[input.dng]$c_reset"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$c_head""Options:$c_reset"
|
echo "$c_head""Options:$c_reset"
|
||||||
|
|||||||
+1
-6
@@ -45,12 +45,7 @@
|
|||||||
# edit --editor=code --clipboard
|
# edit --editor=code --clipboard
|
||||||
# edit --text="hello world"
|
# edit --text="hello world"
|
||||||
function edit --description 'Open files in a terminal or GUI editor with fallbacks'
|
function edit --description 'Open files in a terminal or GUI editor with fallbacks'
|
||||||
set -l c_head (set_color --bold cyan)
|
__fish_palette
|
||||||
set -l c_cmd (set_color --bold)
|
|
||||||
set -l c_flag (set_color yellow)
|
|
||||||
set -l c_err (set_color red)
|
|
||||||
set -l c_dim (set_color brblack)
|
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
|
|
||||||
# Opinionated guard (C1): fall back to the legacy bare-editor behavior.
|
# Opinionated guard (C1): fall back to the legacy bare-editor behavior.
|
||||||
if not __fish_config_op_enabled (status current-function)
|
if not __fish_config_op_enabled (status current-function)
|
||||||
|
|||||||
+1
-2
@@ -19,8 +19,7 @@
|
|||||||
function hist --description 'Search fish history and put it in the prompt'
|
function hist --description 'Search fish history and put it in the prompt'
|
||||||
# Opinionated guard (C4): integrations disabled
|
# Opinionated guard (C4): integrations disabled
|
||||||
if not __fish_config_op_enabled (status current-function)
|
if not __fish_config_op_enabled (status current-function)
|
||||||
set -l c_err (set_color red)
|
__fish_palette
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
echo "$c_err"'hist: disabled by __fish_config_op_integrations'"$c_reset" >&2
|
echo "$c_err"'hist: disabled by __fish_config_op_integrations'"$c_reset" >&2
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,11 +41,7 @@
|
|||||||
# NOTES
|
# NOTES
|
||||||
# Typo abbreviation: url-open (expands to open-url on space/enter).
|
# Typo abbreviation: url-open (expands to open-url on space/enter).
|
||||||
function open-url --description 'Open a URL in the best available web browser'
|
function open-url --description 'Open a URL in the best available web browser'
|
||||||
set -l c_head (set_color --bold cyan)
|
__fish_palette
|
||||||
set -l c_cmd (set_color --bold)
|
|
||||||
set -l c_flag (set_color yellow)
|
|
||||||
set -l c_arg (set_color cyan)
|
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
|
|
||||||
argparse h/help s/silent v/verbose -- $argv
|
argparse h/help s/silent v/verbose -- $argv
|
||||||
or return 1
|
or return 1
|
||||||
|
|||||||
+1
-5
@@ -28,11 +28,7 @@
|
|||||||
function p --description 'Put from clipboard'
|
function p --description 'Put from clipboard'
|
||||||
# Check for help flag
|
# Check for help flag
|
||||||
if contains -- -h $argv; or contains -- --help $argv
|
if contains -- -h $argv; or contains -- --help $argv
|
||||||
set -l c_head (set_color --bold cyan)
|
__fish_palette
|
||||||
set -l c_cmd (set_color --bold)
|
|
||||||
set -l c_flag (set_color yellow)
|
|
||||||
set -l c_dim (set_color brblack)
|
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
echo "$c_head""Usage:$c_reset $c_cmd""p$c_reset $c_flag""[OPTIONS]$c_reset"
|
echo "$c_head""Usage:$c_reset $c_cmd""p$c_reset $c_flag""[OPTIONS]$c_reset"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Pastes content from the system clipboard to stdout."
|
echo " Pastes content from the system clipboard to stdout."
|
||||||
|
|||||||
@@ -36,11 +36,7 @@
|
|||||||
# play-media
|
# play-media
|
||||||
# play-media --player mpv
|
# play-media --player mpv
|
||||||
function play-media --description 'Pick audio/video files with fzf and play them'
|
function play-media --description 'Pick audio/video files with fzf and play them'
|
||||||
set -l c_head (set_color --bold cyan)
|
__fish_palette
|
||||||
set -l c_cmd (set_color --bold)
|
|
||||||
set -l c_flag (set_color yellow)
|
|
||||||
set -l c_dim (set_color brblack)
|
|
||||||
set -l c_reset (set_color normal)
|
|
||||||
|
|
||||||
argparse h/help p/player= -- $argv
|
argparse h/help p/player= -- $argv
|
||||||
or return 1
|
or return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user