Okay, here are a few angles of attack:
1) Simplify. Have you tried the commands outside of the alias to see if it works?
/usr/bin/mate -w ~/.bashrc; source ~/.bashrc
A better test might be with a file that doesn't exist yet:
FILE=$TMPDIR/matewaiting-$(uuidgen); /usr/bin/mate -w $FILE; ls -al $FILE
If you get a file listing, it waited. If you get an error even though you typed something in the file and saved it, then it didn't.
2) Multiple binaries in $PATH
. You didn't mention what version you're using, we should check...
$ mate --version
mate 2.4 (2013-11-03 revision 9495)
If you didn't get that but instead something like mate r1577 (2012-07-11)
, then you have multiple mate binaries in your $PATH
and you're using the old one. In that case, run the following repeatedly and move/rename/trash any older mate/mate_wait's until you finally see the latest...OR run out of matching commands in your $PATH
:
for MATE in mate{,_wait}; do
p="$(which $MATE)"
echo "$p: $("$p" --version)"
done
Actually, you should probably remove new ones too, since they may have been cp
'ed in (you can never be too paranoid with your OS :-). The following command will hard-link the commands into your /usr/local/bin so that they are updated automagically when/if they get updated by a TextMate 2 update:
# This is just in case you changed the TM2 bundle name in /Applications
# Using Spotlight...might as well, since it turns every Mac into a heliport...
[[ -n "$TM2" ]] || TM2="$(mdfind '(kMDItemCFBundleIdentifier=com.macromates.TextMate.preview)')"
if [[ -n "$TM2" ]]; then
# Search for the mate binary within the TM2 directory
MATE="$(find "$TM2" -name mate)"
if [[ -n "$MATE" ]]; then
# Hard-link both mate and mate_wait to the
# mate binary into /usr/local/bin
for cmd in mate{,_wait}; do
ln -f "$MATE" /usr/local/bin/$cmd
echo "Linked /usr/local/bin/$cmd to $MATE"
done
else
echo "ERROR: No mate found in $TM2"
fi
else
echo "ERROR: Could not find TextMate 2 app bundle in /Applications."
echo "Please set TM2 environment variable with full path"
fi
This, of course, assumes you HAVE a /usr/local/bin
and that it's actually in your $PATH
(hopefully in FRONT of /usr/bin
and /usr/sbin
)...
3) Ditch the alias! I also have a realias but mine is a function (read: better for anything more than an alias as the dictionary defines it) and it was crafted with slightly more defensive programming (i.e. against my greatest enemy: me!). This from my .aliases
file
# Remove all aliases
unalias -a
alias aliases='alias '
# Re-read the aliases
realias() {
local editor="${VISUAL:-emacs}"
if [[ -z $editor ]]; then
echo "realias: VISUAL environment variable unset" > /dev/stderr
return
fi
[[ "$editor" =~ .*mate$ ]] && editor="$editor -w "
"$editor" $HOME/.aliases
source $HOME/.aliases
}
$VISUAL
is set in my .bashrc to emacs, though on Mac OS X, it gets reset later to $(which mate 2>/dev/null)
.
Works for me. Is your
bashrc
syntax okay? – slhck – 2011-11-22T22:15:49.140Yes, for sure.. – Misha Moroshko – 2011-11-22T22:55:02.070
Well, I tested on 10.6 with TextMate 1.5.10 (latest, afaik). Maybe you found a bug? Am I reading this right, your shell just does not work anymore? – slhck – 2011-11-22T22:58:25.250
Once you solve the non-returning shell issue, you may want to put an
unalias -a
command before thesource
command in the definition so any deletions you make in the editor will be reflected in the current shell's new alias set. F/ex, if you found you'd accidentally made a dangerous alias and you use yourb
alias to edit it out, the present definition would leave the bad alias in the current shell, waiting to bite you. – JRobert – 2011-11-23T01:11:43.390