There is a pretty awesome applescript called "Open Terminal Here" ( http://www.entropy.ch/software/applescript/ ) which you can add to your finder's toolbar and click when you want to launch a terminal console which is set to that directory.
Sometimes I need to be root, and so I end up starting terminal, doing something like sudo -i
and then I have to change back to the previous directory because the sudo command is landing me in /var/root.
I'm using sudo -i because I like it to load things like aliases / the bash profile.
The script is applescript, and here's the important part of how it works:
... set cmd to "cd " & quoted form of the_path & " && echo $'\\ec'" ... tell application "Terminal" activate do script with command cmd
How do I get this to load as root?
sudo -i
because you specifically want to run root's .profile, instead of your own? Because if it's just a case of wanting to make sure certain shell initialization files get run, that might be easier to fix and it would allow you to switch to usingsudo -s
to get a root shell without changing your working directory./etc/profile
file which I believe is like a global.bash_profile
- that is supposed to load for all users. I have an alias command in therealias ll="ls -al"
and if I runsudo -i
then I have access to thell
command, but if I runsudo -s
then thell
command doesn't work. But you're right, the directory doesn't change. So how can I use applescript to launch Terminal as root?~/.bashrc
is sourced for non-login shells. My own practice was to put all of my aliases and such in~/.bashrc
, and add a. ~/.bashrc
line to the end of my~/.bash_profile
. The OS X bash(1) manpage doesn't indicate a system-wide equivalent to ~/.bashrc, though some other man pages suggest /etc/bash.bashrc is used.alias ll="ls -al"
to all of them but it's not working for any. This actually would be the simplest solution if I could get it to work! Also, I have an /etc/bashrc file, with a comment line# System-wide .bashrc file for interactive bash(1) shells.
at the top. but it too, has let met down.