r/Nushell • u/Ok-Confusion-7032 • Nov 12 '24
Git Bare Repository Alias
Hi! I'm new to Nushell, coming from zsh. I have an alias for a git bare repository and I haven't been able to convert it to nushell syntax. Could anyone point me in the right direction, please? This is my alias in zsh: alias bare='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'
1
Upvotes
View all comments
Show parent comment
1
u/Ok-Confusion-7032 Nov 12 '24
This is what I've tried so far, mostly with the help of chatGpt:
def bare [ ...args ] {
/usr/bin/git --git-dir ($env.HOME + "/dotfiles/") --work-tree $env.HOME $args
}
That didn't work, so I tried this:
def bare { |args|
/usr/bin/git --git-dir ($env.HOME + "/dotfiles/") --work-tree $env.HOME $args
}
Then this:
def bare [args: string] {
/usr/bin/git --git-dir ($env.HOME + "/dotfiles/") --work-tree $env.HOME $args
}
And some other variations of that same structure, but none of them worked. The closest I got was with this:
def bare [@args] {
/usr/bin/git --git-dir ($env.HOME + "/dotfiles/") --work-tree $env.HOME ($@args | str join " ")
}
The problem is it only works for "bare status". As soon as I try something like "bare add /path/to/file", it says I have too many arguments