Script in PATH Mac OSX terminal not working - emacs

I have the following script in my /path/to/startupscripts directory, so I can open the emacs GUI with the command 'emacs':
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs "$#"
I edited my ~/.bash_profile and added the following line
export PATH=/path/to/startupscripts/emacs:$PATH
However, the script is not working because when I type in 'emacs' into the command line emacs still opens within terminal and not the GUI like I want. Also, when I am in the /path/to/startupscripts directory and I can execute and run the script with
chmod +x emacs
./emacs
but even when I type 'emacs' afterwards it still opens within terminal. I am a bit of a beginner, and I think I am missing something painfully obvious.

The PATH should contain a directory name where your script(s) can be found, not the name of your individual script.

You probably need to source your .bash_profile:
source ~/.bash_profile
No changes made in your profile will be applied unless you source the profile or log out and back in.
Aside from that every looks like it should work.
However you may want to consider just using an alias instead of a script for this. This can be done by adding this to your profile:
alias emacs=/Applications/Emacs.app/Contents/MacOS/Emacs
That's probably a cleaner way to get the functionality you want without adding more to your PATH variable.
I hope that helps! [insert obligatory comment about how you should be using vim and not emacs :P]

Related

Swift on Ubuntu 20.04- Need to add a path every time

I am simply trying to install swift on linux
I have downloaded the files from swift.org, extracted .tar files and used export command to include the path after that when I use swift --version it correctly shows the version 5.3.3 but when I close the terminal and try to open the swift command terminal it says command not found.
What is happening here? I need to include the path every time I open the terminal.
The export command just adds the value to path for the current session. When you log out and in again, it will reset.
You need to add this to your shell resource file so that it gets added to the path every time you log in. The file you need to edit will be called .zshrc or .bash_profile or something similar. You should start by opening the command line on your computer and verifying what shell you are running by typing:
echo $SHELL
This will return something like /bin/ksh or /bin/bash or similar. Then do a little internet searching to find out what the resource file is called for that shell. Then edit your resource file to add the Swift path to your $PATH.

Emacs term pastes strange line into terminal when changing directories

I am using fish terminal inside of Emacs term
My normal prompt on load looks like the following
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
$>
Ok, when I load fish term inside of term.el it looks like this
Welcome to fish, the friendly interactive shell
Type helpB for instructions on how to use fish
7;file://Collins-MacBook-Air.local/Users/collinbell/Programs/riddley⏎
$>
A cd command in my normal terminal looks like this
$> cd ~/
$>
However in the emacs term.el it looks like this
$> cd ~/
7;file://Collins-MacBook-Air.local/Users/collinbell⏎
$>
I have no idea why it is pasting the cwd into the buffer, but it does it every time a directory changes. Emacs also makes the system sound after this, while other commands like ls do not make the system sound.
This is obviously not the biggest issue in the world, but I do run clear as a pre-command to keep my terminal looking clean (although I turned it off for this example) and Emacs pasting this line into the buffer really messes with sublime usage.
You seem to be experiencing a known issue.
Try this fix:
In your fish config file ~/.config/fish/config.fish add the following:
function fish_title
true
end
Also, see this from the fish documentation, though according to the github issue, the fix suggested in the docs might not work, while the above function does.
According to the fish documentation, this is what's going on:
Fish is trying to set the titlebar message of your terminal. While
screen itself supports this feature, your terminal does not.
Unfortunately, when the underlying terminal doesn't support setting
the titlebar, screen simply passes through the escape codes and text
to the underlying terminal instead of ignoring them. It is impossible
detect and resolve this problem from inside fish since fish has no way
of knowing what the underlying terminal type is. For now, the only way
to fix this is to unset the titlebar message, as suggested above.

How can I run vim from PowerShell just by typing vim?

I just installed vim. It's awesome. From PowerShell, I want to be able to launch it both via typing vim and by typing vim someFile.txt.
I can already open vim through the run dialog. Further, it's already in my system PATH. What must I do to launch it from PowerShell?
If it's already in the path, it should work.
But you can, alternatively, use an alias via New-Alias. If you add that to your profile, it will load every time.
To see how the run box behaves differently from powershell, and how you might get around that, see my answer here:
Run a program by name from PowerShell (similarly to the run box)

How to add mongo commands to PATH on Mac OSX

I'm using MongoDb 2.6.1 following the material from https://university.mongodb.com/ (great material by the way) but I am not being able to add to my path the mongo commands.
I've followed this guide http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ and I modified my .bashrc like this
export PATH=/Users/jonathancaballero/bin/mongodb/mongodb_2.6.1/bin:$PATH
And there is indeed where the binaries are (checked using the finder directly)
So my question is why I am not able to use mongod from any location in my terminal?
Please put the PATH export into .bash_profile:
export PATH=/path/to/your/mongo/bin:$PATH
Edit: The reason to put it into .bash_profile is that this file will usually get executed when bash is started as a login shell while .bashrc usually is exectuted for interactive non-login-shells. What usually happens is that .bashrc gets sourced in .bash_profile. This does not seem to be the case here. On MacOS X when you start a Terminal, .bashrc does not get executed. God knows why, as the shell opened should be an interactive non-login shell and therefor should execute .bashrc.
Another, albeit more "intrusive" solution would be to add the following to .bash_profile.
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
For those who are interested in the details: take a look into the according sections of bash's manpage

Eclipse: Add Command-Line Args to an OS X .app Directory

Is it possible to add custom command-line arguments to an Eclipse .app folder? In my particular case, I'm working with ZendStudio. I'm assuming the base Eclipse release would behave the same way.
I've found what looks like two different places that could work, but neither yield any results:
ZendStudio.app\Contents\info.plist
ZendStudio.app\Contents\MacOS\ZendStudio.ini
Am I looking in the right place, or is this even possible?
If you mean that you want to start Eclipse with some command line arguments, there is no file where you can add those to be used as default. But you can make a small script that will start Eclipse with the arguments you want, something like:
/Applications/Eclipse.app/Context/MacOS/eclipse some command line arguments
and then add executable permissions to your script, through Terminal window:
chmod 755 your_file
you can just type "chmod 755 " on the terminal and then drag and drop the script file on the terminal window, it will type the file's full path onto it, press ENTER and that's it. You can double-click your script file and it will start up Eclipse with the command line arguments you typed.