cd into /Contents/ in Automator - bash

I've got my Automator project, and what I want to do is cd (change directory) into "itself" (as if you'd click Show Package Contents). How may I do that?
From there, I can create folders, create files, etc., I've got that part, however I don't know how to change directory into the Contents of my .app.

Related

Make link to Application folder

Sublime Text editor has in DMG file link to Applications dir (blue icons with arrow). It has small size.
How to make such link on my own folder? It must work in all Macs.
Open the terminal, use cd to open the folder where you want to create the symbolic link (this is how that kind of link is called, in case you want to research a bit more about it). Example:
cd /Users/MyUser/Desktop/
Note: In case the path has spaces, write it with backslashes before each space, like that:
cd /Users/MyUser/Desktop/My\ Folder/
Then, use that command to create it:
ln -s /Applications/ Applications
It will create a symbolic link which opens the path /Applications/, which means that it will work in any macOS computer.
Reference:
https://apple.stackexchange.com/a/115648

Set global working directory alias in Git bash (Windows)

I've been trying for literally hours to set a global alias that I can use when I open Git bash on my Windows machine to cd to a specific location.
I want to be able to simply type the alias to get to the location. I've tried every which way. The attempt that got me closest was based on this: https://superuser.com/questions/602872/how-do-i-modify-my-git-bash-profile-in-windows
...but it seems that to get it to work upon relaunching of bash, I have to use source .bashrc, which I don't want to do. Help appreciated.
I just jury rigged a solution with a simple shell script that acts like a global alias. If someone has a better solution, please do tell.
Opened text editor and wrote the following two lines:
#!/bin/bash
cd blah/blep/directory_of_choice
Saved it as a text file with a descriptive name (like dirjump) somewhere and copied it.
In file explorer, navigated to the bin folder in the MinGW64 installation, e.g. "C:\Program Files\Git\mingw64\bin"
Pasted the file into this bin folder.
While viewing the contents of the bin folder referenced above in Windows file explorer, from the menu bar selected "view > options", which opened the "folder options" dialog. Selected the "view" tab here and unchecked "Hide extensions for known file types" and clicked ok.
Deleted the ".txt" extension from the file copied into the bin folder.
To call this shell script that has the same result as a global alias, typed the following in Git bash:
. dirjump (the space between the dot and the dirjump MUST be included)

Vim ctrlp plug in loading all files in my computer instead of current directory

I'm using MacVim with the ctrlp plug in for a file finder. It's supposed to load files in just the current directory to the file buffer. For example, I used to be able to cd into a directory, and then type mvim at the command line. That would load all the files in the current directory and only that directory, which was awesome for, say, a Rails project. Then my file finds would only search in that directory.
Recently, though, when I type mvim in a certain directory, the vim file buffer is all the files on my computer, rather than in the current directory, so finding the exact index.html.haml I need is impossible.
The weird thing is that when I say mvim ., it only tells me the files and folders in the current directory, which I would expect. And when I type :pwd, it tells me that the path I'm in is the current directory (a Rails project). But when I type ,t to find a file, it's all the files on my computer.
Here is a screenshot. I've cded into a Rails project and have typed ,t to bring up the file navigator using the ctrlp plugin, and I typed config.rb which should only bring up that directory's config.rb file, but instead, it's all the config.rb's on my system!
I went to the GitHub page for ctrlp to file an issue and came across this issue. The suggested fix for an issue was to turn off starting in the current directory as a default behavior, so I just explicitly added the default to ~/.vimrc, which fixed it:
let g:ctrlp_working_path_mode = 0
EDIT
While adding that line to my ~/.vimrc did indeed fix the problem, it didn't address the root cause of this issue. The creator of the ctrlp suggested that I had created a git repository in my home folder (which ctrlp was looking in), which I somehow had. So another, more root fix for this issue was to just remove the .git directory in my home folder:
$ rm -r ~/.git
Try this:
let g:ctrlp_cmd = 'CtrlP .'

How can I view the User/Library/LaunchDaemons folder within the finder?

Within the finder I can view the contents of User/Library and can see many folders there, however I cannot see a folder called LaunchDaemons.
However if I navigate to the Library folder from the terminal command line then LaunchDaemons is visible.
How can I make it appear in the Finder?
I've tried this command but it didn't have any effect
defaults write com.apple.Finder AppleShowAllFiles YES
There is (at least by default) no LaunchDaemons folder in the user Library. You may be navigating to one of the other Library folders in Terminal. You can check this with the commands pwd (which prints the full path to the current folder -- if it doesn't start with /Users/youraccountname/Library, you aren't in your user Library) and open . (which opens the current folder in the Finder -- and again, I'm pretty sure it won't be inside your user Library).

Executing binary files with a shebang

I created a simple program that takes the path of a directory as an input, creates an archive of that directory (converting it into a single file), adds a shebang to that file (so that the contents of the file can be easily extracted), and writes the file to the base directory of the specified path.
The problem is that the file does not extract itself when I double click on it. Instead the operating system (I'm using Ubuntu 11.10) tries to open it with gedit. This obviously shows the shebang, random gibberish, and the contents of the archived files.
I made the file executable, first by using chmod +x; and when it still didn't work I tried chmod 777. However it still refuses to execute the file with the shebang when I double click on it. Perhaps this is because it's not a pure text file.
Interestingly when I try to execute the file directly from command line it reads the shebang and extracts the contents of the archive properly. So there's nothing wrong with my file format. I don't know much about what operating systems do when you double click on a file but I would sure like to understand.
It surely makes no sense to add a shebang to a file if you still need to manually execute it from the command line. One advantage could be that you don't need to specify the program to open it with but I believe that's hardly an advantage. Any help will be greatly appreciated.
Update 1:
The program that creates the archive is called opm. It can be installed via the node package manager using the following command:
npm install opm
After that you simply use opm to pack and unpack directories for you. For example if I have a directory called test in my home directory then I can open a terminal and execute the following command to pack it:
opm test
This will create an archive of the directory called test.pack in the home directory. The .pack file has the shebang #!/usr/bin/opm. Opening a file with the extension .pack with opm tells it that it's an archive and opm unpacks it in the same directory.
Note: Change the name of the test.pack file if you do not want it to overwrite your existing test directory.
I added the shebang to the .pack file so that it would extract itself when I opened it. However that doesn't seem to work. Nevertheless if I run one of the following command then it works:
./test.pack
You may check my source code and make any modifications to the program as you may wish to.
Update 2:
Alright I created the following .desktop file for opm and stored it in the $HOME/.local/share/applications/ directory:
[Desktop Entry]
Type=Application
Version=1.0
Encoding=UTF-8
Name=OPM
GenericName=Object Packer and Minifier
NoDisplay=true
Comment=JavaScript Package Manager
TryExec=opm
Exec=opm %f
Terminal=false
MimeType=application/opm
Now I was able to associate .pack files with opm by right clicking on a .pack file, going to the Properties window, the Open With tab, and setting opm.desktop as the default application. Now I am able to unpack a .pack file by simply opening it.
However I would like to know how to associate .pack files with the mime type application/opm. Currently the .pack files are associated with application/x-java-pack200. How do I do so? Is it better if I use a different extension (e.g. .opm)? By associating the packed archives with the mime type application/opm will the OS open them with opm by default without having to explicitly set a default application from Properties > Open With?
If there's already a MIME-type associated with .pack then you'll want to use a different extension (.opm) to associate with your MIME-type (application/opm). The way you automatically associate a program that opens files of a specific MIME-type is with xdg-mime .
Alternatively,
Edit ~/.local/share/applications/mimeapps.list and put your MIME/application combo under [Default Applications] like so:
[Default Applications]
application/opm=opm.desktop;
Place your opm.desktop file in ~/.local/share/applications/ folder. (You've already done this)

Resources