I'm runnning fish shell for a test for a few days. So i decided to use my already shell script programs. All of them are working fine, except for one: mkcd
Here is the code:
#!/usr/bin/env bash
dir=$1
mkdir -p "$dir"
cd "$dir" || exit 1
The expected behaviour is to create a new directory and automatically execute a cd
to that directory. But it's not working that way. The program create the directories but doesn't move to the new directory.
This program is located in $HOME/.local/bin
with these other programs:
gc* guntrack* lvim* mkcd* nvims* path* tao*
All of those other shell script programs just work
You can find them here: My dotfiles
This is my fish config, located in $HOME/.config/fish/config.fish
:
fnm env --use-on-cd | source
zoxide init fish | source
set -gx PATH ~/.local/forfish $PATH
#THATS THE LINE WHERE I SPECIFY THE PATH TO PROGRAM
set -gx PATH ~/.local/bin $PATH
alias vif 'fd --type f --hidden --exclude .git --exclude .vscode --exclude node_modules --print0 | fzf --layout=reverse --height=50% --read0 --print0 --exit-0 | xargs -r -0 nvim'
alias vi nvim
alias vid "nvim ."
abbr g git
alias rm trash-put
I'm using Oh my fish
My fish version: fish, version 3.6.1
My bash version: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
About my system:
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo
Note, I found a solution using fish functions, but I really want to understand why the shell script is not working.
Following the function in fish that works:
function makedir -d "Create a directory and cd"
mkdir -p $argv
cd $argv
end
This function works fine if you put it inside the config.fish
file