Reputation: 17
I made a pretty long alias and I can't get it to work. I put it in ~/.bash_profile. Here is it:
alias venga='cd ~/Users/clem/Desktop/venga/ ; echo "Vous êtes dans le dossier venga de votre site web." ; echo " " ; echo "Pour ajouter un commit, utilisez :" ; echo "git commitcommit -am "Message du Commit" ; echo " " ; echo "Pour envoyer le dossier vers GitHub, utilisez :" ; echo "git push origin master" ; echo " " ; echo "Pour ajouter un fichier à git utilisez :" ; echo "git add nomdufichier.xx"'
Here's the output:
$ venga
>
When I hit enter, other arrows appear below. I don't know what to do.
Upvotes: 0
Views: 55
Reputation: 295272
Write this as a function, not an alias:
venga() {
cd /Users/clem/Desktop/venga/ || {
echo "Impossible d'accéder au répertoire du site Web"
return
}
echo 'Vous êtes dans le dossier venga de votre site web.'
echo
echo 'Pour ajouter un commit, utilisez :'
echo 'git commitcommit -am "Message du Commit"'
echo
echo 'Pour envoyer le dossier vers GitHub, utilisez :'
echo 'git push origin master'
echo
echo 'Pour ajouter un fichier à git utilisez :'
echo 'git add nomdufichier.xx'
}
Allows error handling, makes the code much easier to read -- and moots the quoting concerns that caused you trouble with the alias form.
(I also fixed up ~/Users/clem/Desktop/venga
to /Users/clem/Desktop/venga
, as the former was looking for something like $HOME/Users/clem/Desktop/venga
, and you probably don't have Users
under $HOME
).
Upvotes: 1
Reputation: 41203
You have an unclosed quote, due to the unescaped quote in:
echo "git commitcommit -am "Message du Commit" ;
The >
is a continuation prompt, because the shell is waiting for you to close the quote. You don't need an alias to see this happening:
$ echo "Hello
>
>
> world"
Hello
world
$
You probably intended to have:
echo "git commit -am \"Message du Commit\""
... or ...
echo 'git commit -am "Message du Commit"'
But quoting in the shell is a bit of a minefield at the best of times.
A cleaner way of outputting many lines to stdout is cat
with a here document:
cat << END
Hello
"World"
DONE
Upvotes: 1
Reputation: 2981
You have mismatched ".
I think the guilty part is:
echo "git commitcommit -am "Message du Commit"
Here's the fixed version:
alias venga='cd ~/Users/clem/Desktop/venga/ ; echo "Vous êtes dans le dossier venga de votre site web." ; echo " " ; echo "Pour ajouter un commit, utilisez :" ; echo "git commitcommit -am \"Message du Commit\"" ; echo " " ; echo "Pour envoyer le dossier vers GitHub, utilisez :" ; echo "git push origin master" ; echo " " ; echo "Pour ajouter un fichier à git utilisez :" ; echo "git add nomdufichier.xx"'
Also you'll probably be better off putting this instructions in a separate file, that you just cat
, rather than having a number of echos.
Upvotes: 0