Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/command/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class AddCommand extends BaseCommand {

if (this.config.change_directory) {
/* istanbul ignore next */
if (process.platform === 'darwin') {
if (process.platform === 'darwin' || process.env.TERM_PROGRAM === 'Warp') {
const script = utils.generateAppleScript(targetPath);
this.logger.info(`Change directory to ${targetPath}`);
await this.runScript(script);
return;
}
this.logger.error('Change directory only supported in darwin');
this.logger.error('Change directory only supported in darwin and Warp environments');
}

try {
Expand Down
4 changes: 2 additions & 2 deletions lib/command/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class FindCommand extends BaseCommand {
const dir = key;
if (this.config.change_directory) {
/* istanbul ignore next */
if (process.platform === 'darwin') {
if (process.platform === 'darwin' || process.env.TERM_PROGRAM === 'Warp') {
const script = utils.generateAppleScript(dir);
this.logger.info(`Change directory to ${dir}`);
await this.runScript(script);
return;
}
this.logger.error('Change directory only supported in darwin');
this.logger.error('Change directory only supported in darwin and Warp environments');
}
await this.copyPath(repo, dir);
}
Expand Down
20 changes: 19 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,27 @@ exports.generateAppleScript = dir => {
end tell
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');

const warpCommand = `tell application "Warp"
tell current session of current window
write text "cd ${dir}"
end tell
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');

const currentApp = `tell application "System Events"
set activeApp to name of first application process whose frontmost is true
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');

return `[ \`osascript ${currentApp}\` = "Terminal" ] && osascript ${terminalCommand} >/dev/null || osascript ${iTermCommand}`;
if (process.env.TERM_PROGRAM === 'Warp') {
return `osascript ${warpCommand}`;
} else {
return `[ \`osascript ${currentApp}\` = "Terminal" ] && osascript ${terminalCommand} >/dev/null || osascript ${iTermCommand}`;
}
};

exports.generateWarpScript = dir => {
return `tell application "Warp"
tell current session of current window
write text "cd ${dir}"
end tell
end tell`.split('\n').map(line => (` -e '${line.trim()}'`)).join('');
};