Skip to content

Commit

Permalink
Merge pull request #42 from jbtule/3.1-clean-up
Browse files Browse the repository at this point in the history
3.1 clean up
  • Loading branch information
jbtule authored Oct 11, 2019
2 parents 1fbb7da + d4e8818 commit 61ec626
Show file tree
Hide file tree
Showing 38 changed files with 118 additions and 2,736 deletions.
44 changes: 36 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## cd to...
## cd to... [![Latest Release](https://img.shields.io/github/release/jbtule/cdto.svg)](https://github.com/jbtule/cdto/releases/latest)
<img src="https://raw.github.com/jbtule/cdto/master/graphics/lion.png" height="128px" width="128px" />

Finder Toolbar app to open the current directory in the Terminal.
Expand All @@ -14,19 +14,47 @@ https://github.com/jbtule/cdto
Download [Latest cdto.zip](https://github.com/jbtule/cdto/releases/latest)


To install "cd to ....app" copy to your Applications folder, and then from the applications folder drag it into the Finder toolbar (10.9 Mavericks later required ⌘ + ⌥) or drag from another finder window to toolbar being customised
To install "cd to ....app" copy to your Applications folder, and then from the applications folder ⌘ drag it into the Finder toolbar or drag from another finder window to toolbar being customized.

To use, just click on the new button and instantly opens a new terminal window.

### Settings

To turn on feature that identifies automatically opened Terminal windows, and closes them when using *cd to*.

```bash
defaults write name.tuley.jay.cd-to cdto-close-default-window -bool true
```

To change the window scheme for Terminal Windows from default.

_Eg. if you wanted cd to windows to be "Red Sands"_

```bash
defaults write name.tuley.jay.cd-to cdto-new-window-setting -string "Red Sands"
```

To use, just click on the new button and instanly opens a new terminal window.

For old versions to use with iTerm or X11/xterm, using the finder contextual menu "show package contents" and exchange the plugins in the Plugin/Plugin Disabled folders respectively. Next time you run "cd to ..." it should open with the correct application.


### Changes:

Version 3.1
* Restored name to "cd to.app"
* *bug* fix 3.0 introduced bug for opening windows without selection
* Faster
* Fix Regression: Hide icon in dock
* if package is selected, cd parent directory, if in package cd own directory
* Less entitlements
* Setting to enable feature that closes extra opened windows
* Setting to enable choosing a different terminal theme for opened windows


Version 3.0
* temrinal app only supported, no plugins
* rewritten to only use apple events
* notatized
* works on mojave (and hopefully catalinaj
* terminal app only supported, no plugins
* rewritten to only use apple events
* Hardened, and Notarized
* works on Mojave (and hopefully Catalina)

Version 2.6
* Fixed bug where get info window interferes
Expand Down

This file was deleted.

8 changes: 5 additions & 3 deletions cd to .../cd to .../Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
<true/>
<key>NSAppleEventsUsageDescription</key>
<string>Queries Finder and opens Terminal to it's location</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Jay Tuley. All rights reserved.</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
<key>NSAppleEventsUsageDescription</key>
<string>Queries Finder and opens Terminal to it&apos;s location</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<key>com.apple.security.automation.apple-events</key>
<true/>
</dict>
</plist>
12 changes: 0 additions & 12 deletions cd to .../cd to .../cd_to____.entitlements

This file was deleted.

60 changes: 55 additions & 5 deletions cd to .../cd to .../main.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
#import "Finder.h"
#import "Terminal.h"

NSUInteger linesOfHistory(TerminalTab* tab) {
NSString* hist = [[tab history] stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
return [[hist componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]] count];
}

int main(int argc, const char * argv[]) {
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
Expand All @@ -20,25 +25,70 @@ int main(int argc, const char * argv[]) {
TerminalApplication* terminal = [SBApplication applicationWithBundleIdentifier:@"com.apple.Terminal"];

FinderItem *target = [(NSArray*)[[finder selection] get] firstObject];
FinderFinderWindow* findWin = [[finder FinderWindows] objectAtLocation:@1];
findWin = [[finder FinderWindows] objectWithID:[NSNumber numberWithInteger: findWin.id]];
bool selected = true;
if (target == nil){
target = [[[[finder FinderWindows] objectAtLocation:@0] target] get];
target = [[findWin target] get];
selected = false;
}

if ([[target kind] isEqualToString:@"Alias"]){
target = (FinderItem*)[(FinderAliasFile*)target originalItem];
}

NSString* fileUrl = [target URL];
if(fileUrl != nil && ![fileUrl hasSuffix:@"/"]){
if(fileUrl != nil && ![fileUrl hasSuffix:@"/"] && selected){
fileUrl = [fileUrl stringByDeletingLastPathComponent];
}

NSURL* url = [NSURL URLWithString:fileUrl];


if (url != nil){
[terminal activate];
TerminalWindow* win = nil;
if ([[terminal windows] count] == 1){
//get front most and then reference by id
win = [[terminal windows] objectAtLocation:@1];
win = [[terminal windows] objectWithID: [NSNumber numberWithInteger:win.id]];
}
[terminal open:@[url]];
//get front most and then reference by id
TerminalWindow* newWin = [[terminal windows] objectAtLocation:@1];
newWin = [[terminal windows] objectWithID: [NSNumber numberWithInteger:newWin.id]];
TerminalTab* newTab = [[newWin tabs] objectAtLocation:@1];

NSString* setName = [[NSUserDefaults standardUserDefaults] stringForKey:@"cdto-new-window-setting"];
if(setName != nil && ![setName isEqualToString:@""]) { //setting set
TerminalSettingsSet* chosenSet = nil;
for (TerminalSettingsSet *set in [terminal settingsSets]) {
if([[set name] isEqualToString:setName]){
chosenSet = set;
}
}
if(chosenSet != nil){
newTab.currentSettings = chosenSet;
}
}

if([[NSUserDefaults standardUserDefaults] boolForKey:@"cdto-close-default-window"]){ //close first launch window
if([[win tabs] count] == 1){
TerminalTab* tab = [[win tabs]objectAtLocation:@1];
if(![tab busy]){
//if history has same number of lines as new window
// assume automatically opened new window, and close it
NSUInteger oldTabLines = linesOfHistory(tab);
while([newTab busy]){
[NSThread sleepForTimeInterval:0.1f];
}
NSUInteger newTabLines = linesOfHistory(newTab);
if(oldTabLines == newTabLines){
[win closeSaving:TerminalSaveOptionsNo savingIn:nil];
}
}
}
}


[terminal activate];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
699EB3B9234DBA0C00CC2315 /* cd to ....app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "cd to ....app"; sourceTree = BUILT_PRODUCTS_DIR; };
699EB3B9234DBA0C00CC2315 /* cd to.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "cd to.app"; sourceTree = BUILT_PRODUCTS_DIR; };
699EB3BF234DBA0D00CC2315 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
699EB3C4234DBA0D00CC2315 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
699EB3C5234DBA0D00CC2315 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
699EB3C7234DBA0D00CC2315 /* cd_to____.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "cd_to____.entitlements"; sourceTree = "<group>"; };
699EB3C7234DBA0D00CC2315 /* cd_to.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = cd_to.entitlements; sourceTree = "<group>"; };
699EB3D2234DBB0700CC2315 /* Finder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Finder.h; sourceTree = "<group>"; };
699EB3D3234DBB0700CC2315 /* Terminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Terminal.h; sourceTree = "<group>"; };
699EB3D4234DC4D800CC2315 /* AppIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon.icns; sourceTree = "<group>"; };
Expand Down Expand Up @@ -45,7 +45,7 @@
699EB3BA234DBA0C00CC2315 /* Products */ = {
isa = PBXGroup;
children = (
699EB3B9234DBA0C00CC2315 /* cd to ....app */,
699EB3B9234DBA0C00CC2315 /* cd to.app */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -59,17 +59,17 @@
699EB3BF234DBA0D00CC2315 /* Assets.xcassets */,
699EB3C4234DBA0D00CC2315 /* Info.plist */,
699EB3C5234DBA0D00CC2315 /* main.m */,
699EB3C7234DBA0D00CC2315 /* cd_to____.entitlements */,
699EB3C7234DBA0D00CC2315 /* cd_to.entitlements */,
);
path = "cd to ...";
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
699EB3B8234DBA0C00CC2315 /* cd to ... */ = {
699EB3B8234DBA0C00CC2315 /* cd to */ = {
isa = PBXNativeTarget;
buildConfigurationList = 699EB3CA234DBA0D00CC2315 /* Build configuration list for PBXNativeTarget "cd to ..." */;
buildConfigurationList = 699EB3CA234DBA0D00CC2315 /* Build configuration list for PBXNativeTarget "cd to" */;
buildPhases = (
699EB3B5234DBA0C00CC2315 /* Sources */,
699EB3B6234DBA0C00CC2315 /* Frameworks */,
Expand All @@ -79,9 +79,9 @@
);
dependencies = (
);
name = "cd to ...";
name = "cd to";
productName = "cd to ...";
productReference = 699EB3B9234DBA0C00CC2315 /* cd to ....app */;
productReference = 699EB3B9234DBA0C00CC2315 /* cd to.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand All @@ -98,7 +98,7 @@
};
};
};
buildConfigurationList = 699EB3B4234DBA0C00CC2315 /* Build configuration list for PBXProject "cd to ..." */;
buildConfigurationList = 699EB3B4234DBA0C00CC2315 /* Build configuration list for PBXProject "cd to" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
Expand All @@ -111,7 +111,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
699EB3B8234DBA0C00CC2315 /* cd to ... */,
699EB3B8234DBA0C00CC2315 /* cd to */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -253,18 +253,19 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "cd to .../cd_to____.entitlements";
CODE_SIGN_ENTITLEMENTS = "cd to .../cd_to.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = VURRGRYW45;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "cd to .../Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 3.0;
PRODUCT_BUNDLE_IDENTIFIER = "name.tuley.jay.cd-to----";
MARKETING_VERSION = 3.1;
PRODUCT_BUNDLE_IDENTIFIER = "name.tuley.jay.cd-to";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -273,26 +274,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "cd to .../cd_to____.entitlements";
CODE_SIGN_ENTITLEMENTS = "cd to .../cd_to.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = VURRGRYW45;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "cd to .../Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 3.0;
PRODUCT_BUNDLE_IDENTIFIER = "name.tuley.jay.cd-to----";
MARKETING_VERSION = 3.1;
PRODUCT_BUNDLE_IDENTIFIER = "name.tuley.jay.cd-to";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
699EB3B4234DBA0C00CC2315 /* Build configuration list for PBXProject "cd to ..." */ = {
699EB3B4234DBA0C00CC2315 /* Build configuration list for PBXProject "cd to" */ = {
isa = XCConfigurationList;
buildConfigurations = (
699EB3C8234DBA0D00CC2315 /* Debug */,
Expand All @@ -301,7 +303,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
699EB3CA234DBA0D00CC2315 /* Build configuration list for PBXNativeTarget "cd to ..." */ = {
699EB3CA234DBA0D00CC2315 /* Build configuration list for PBXNativeTarget "cd to" */ = {
isa = XCConfigurationList;
buildConfigurations = (
699EB3CB234DBA0D00CC2315 /* Debug */,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions old-objc-version/CONTRIBUTORS

This file was deleted.

Binary file removed old-objc-version/English.lproj/InfoPlist.strings
Binary file not shown.
36 changes: 0 additions & 36 deletions old-objc-version/Info.plist

This file was deleted.

Loading

0 comments on commit 61ec626

Please sign in to comment.