3 ms·
I have an "mkcd" function in my startup files: mkcd() { mkdir -vp "$1" && cd "$1"; }
by RhysU 6y ago
I have an "mkcd" function in my startup files:
mkcd() { mkdir -vp "$1" && cd "$1"; }
- cutthegrass2 6y ago+1, I do the same.
- bunsenhoneydew 6y agoMe too
- gpspake 6y agoYep, first thing I add to my dotfiles when I don't have it haha
- alsetmusic 6y agoWait, now I'm confused. I have: mkcd() { mkdir -p "$@" && cd "$_"; } Can someone please detail the differences between $! and $_? (Apologies if I'm missing something obvious)
- tyingq 6y ago$ echo "test" > /dev/null && echo !$ /dev/null $ echo "test" > /dev/null && echo $_ test
- karatinversion 6y agoYou're thinking of $_ and !$, and I think they are equivalent - $_ is explicitly the last argument of the previous command, whereas !$ is a history expansion command. ! starts a new history expansion command, and $ is a word designator for the last word of the selected history entry. To quote man bash, " If a word designator is supplied without an event specification, the previous command is used as the event." I would not that !$ is a bash-ism, whereas $_ works at least on zsh and ksh as well as bash.
- deleted 6y ago[deleted]
- forgotmypw17 6y agoalias tcd='a=`date +%s`;mkdir "$a" && cd "$a"'