diff --git a/functions/_fish_mkdir_p.fish b/functions/_fish_mkdir_p.fish index 21507ad..1943893 100644 --- a/functions/_fish_mkdir_p.fish +++ b/functions/_fish_mkdir_p.fish @@ -44,12 +44,12 @@ function _fish_mkdir_p --description 'mkdir -p with configurable verbose output' if test $mode = path set -l display (string replace -- "$HOME" "~" $target)"/" - echo (set_color --bold cyan)"Created: "(set_color cyan)"$display"(set_color normal) + echo (set_color --bold cyan)"Created directory: "(set_color cyan)"$display"(set_color normal) return 0 end # Tree mode: dimmed existing anchor, then cyan new dirs. - echo (set_color --bold cyan)"Created missing directories:"(set_color normal) + echo (set_color --bold yellow)"Created directories:"(set_color normal) set -l anchor (string replace -- "$HOME" "~" $cursor)"/" echo (set_color brblack)" $anchor"(set_color normal) set -l i 1 diff --git a/functions/mkcd.fish b/functions/mkcd.fish index 9a06fe1..fcc3bd9 100644 --- a/functions/mkcd.fish +++ b/functions/mkcd.fish @@ -22,6 +22,7 @@ function mkcd --description 'Create a directory (with parents) and cd into it' echo echo "$c_head""Flags:$c_rst" echo " $c_flag-h$c_rst, $c_flag--help$c_rst Show this help message" + echo " $c_flag-s$c_rst, $c_flag--silent$c_rst Suppress directory creation output" echo echo "$c_head""Examples:$c_rst" echo " $c_cmd""mkcd$c_rst $c_arg~/projects/myapp$c_rst" @@ -29,13 +30,23 @@ function mkcd --description 'Create a directory (with parents) and cd into it' return 0 end - set -l dir $argv[1] + set -l silent 0 + set -l dir + for _arg in $argv + switch $_arg + case -s --silent + set silent 1 + case '*' + set dir $_arg + end + end set -l is_new 0 - if not test -d $dir - set is_new 1 - command mkdir -p $dir - or return $status + test -d $dir; or set is_new 1 + if test $silent -eq 1 + _fish_mkdir_p --silent $dir; or return $status + else + _fish_mkdir_p --tree $dir; or return $status end cd $dir diff --git a/functions/mkdir.fish b/functions/mkdir.fish index 541c2a9..4f768b8 100644 --- a/functions/mkdir.fish +++ b/functions/mkdir.fish @@ -4,7 +4,16 @@ # Execute mkdir function mkdir --description 'Execute mkdir' if status is-interactive - command mkdir -p $argv + # Fall back to command mkdir -p when flags are present (e.g. -m 755) + for _arg in $argv + if string match -q -- '-*' $_arg + command mkdir -p $argv + return $status + end + end + for _dir in $argv + _fish_mkdir_p --path $_dir + end else command mkdir $argv end