i need to write a bash function that wraps nano such that if the only argument is a directory, it cds there instead
nano
cd
i keep typing nano directoryname/ and absentmindedly hitting enter while thinking about what comes next in the path
nano directoryname/
@monorail One-liner for your ~/.bashrc:
nano() { if [ -d ${!#} ]; then cd ${!#}; else /usr/bin/nano $@; fi }
It checks the last argument, whether it's the only one or not.
@arielmt thank you!
cc: @sireffe
@monorail Mastodon keeps eating the open-bracket between "if" and "-d".
@arielmt @monorail also shouldn't $@ have "" around it? maybe both ${!#} too
Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!
@arielmt thank you!
cc: @sireffe