2
0
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?
Just curious...Do you do
sudo -ibecause 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 -sto get a root shell without changing your working directory. – Spiff – 2011-02-23T05:57:37.523I have a
/etc/profilefile 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 -ithen I have access to thellcommand, but if I runsudo -sthen thellcommand doesn't work. But you're right, the directory doesn't change. So how can I use applescript to launch Terminal as root? – cwd – 2011-02-23T14:47:18.2201FYI:
~/.bashrcis sourced for non-login shells. My own practice was to put all of my aliases and such in~/.bashrc, and add a. ~/.bashrcline 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. – coneslayer – 2011-02-24T16:57:53.797@coneslayer - hmm, i tried to edit all of those files. and no matter what i do, when i run sudo -s I can't get them to be loaded. I added
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. – cwd – 2011-03-04T15:24:25.630i just earned the popular question badge for this one (1k view) but why has nobody upvoted? plz upvote if you found this question helpful. – cwd – 2012-02-20T23:47:37.007