diff --git a/functions/mkd.fish b/functions/mkd.fish new file mode 100644 index 0000000..ff55728 --- /dev/null +++ b/functions/mkd.fish @@ -0,0 +1,32 @@ +function mkd --description 'Create directory(ies) and cd into the first one' + if test (count $argv) -eq 0 + echo "mkd: missing operand" >&2 + return 1 + end + + # Parse options and directories + set -l options + set -l directories + set -l first_dir + + for arg in $argv + if string match -q -- '-*' $arg + set -a options $arg + else + set -a directories $arg + # Store the first directory + if test -z "$first_dir" + set first_dir $arg + end + end + end + + # Create directories with all options + if test (count $directories) -gt 0 + mkdir $options $directories + and cd $first_dir + else + echo "mkd: no directory specified" >&2 + return 1 + end +end diff --git a/functions/y.fish b/functions/y.fish new file mode 100644 index 0000000..8d6d44a --- /dev/null +++ b/functions/y.fish @@ -0,0 +1,9 @@ +function y + set tmp (mktemp -t "yazi-cwd.XXXXXX") + yazi $argv --cwd-file="$tmp" + if read -z cwd < "$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + builtin cd -- "$cwd" + end + rm -f -- "$tmp" +end +