Skip to content

Latest commit

 

History

History
393 lines (322 loc) · 14.8 KB

README-Lite.md

File metadata and controls

393 lines (322 loc) · 14.8 KB


English | 中文 | Deutsch

How to use 🚀

1) Open current directory in Terminal (or Editor)

2) Open selected folder or file in Terminal (or Editor)

3) Open the selected in X (e.g., GitHub Desktop)

How to install 🖥

Homebrew

  1. Run the following command
brew install --cask openinterminal-lite
brew install --cask openineditor-lite
  1. In /Applications folder, hold down the Cmd key and drag the app into Finder Toolbar.

⚠️ macOS will ask your permissions to access Finder and Terminal (iTerm or Hyper) when you run the app for the first time. Please give the application permissions.

Manual

  1. Download from release.
  2. Move the app into /Applications.
  3. Hold down the Cmd key and drag the app into Finder Toolbar.

Support ❤️

Open-source projects cannot live long without your help. If you like OpenInTerminal, please consider supporting this project by becoming a sponsor. Your user icon or company logo shows up on the README with a link to your home page.

Become a sponsor through GitHub Sponsors 💖.

PayPal AliPay WeChat Pay
paypal.me/ji4ning

Settings 🔨

1) Set default terminal (or editor)

You are asked to set the default terminal (or editor) to open after first launch.

The selection box will not appear after you have set the default terminal. If you want to reset the default terminal, please enter the following command in the terminal. Then just run the application again.

# For OpenInTerminal-Lite:
defaults remove wang.jianing.app.OpenInTerminal-Lite LiteDefaultTerminal
# For OpenInEditor-Lite:
defaults remove wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor

Set the following app as the default app to open:

App Command
Alacritty defaults write wang.jianing.app.OpenInTerminal-Lite LiteDefaultTerminal Alacritty
kitty defaults write wang.jianing.app.OpenInTerminal-Lite LiteDefaultTerminal kitty
TextEdit defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor TextEdit
VSCodium defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor VSCodium
BBEdit defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor BBEdit
Visual Studio Code - Insiders defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor Visual\ Studio\ Code\ -\ Insiders
TextMate defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor TextMate
CotEditor defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor CotEditor
MacVim defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor MacVim
Typora defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor Typora
Neovim defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor neovim
Nova defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor Nova
Cursor defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor Cursor
AppCode defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor AppCode
CLion defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor CLion
GoLand defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor GoLand
IntelliJ IDEA defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor IntelliJ\ IDEA
PhpStorm defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor PhpStorm
PyCharm defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor PyCharm
RubyMine defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor RubyMine
WebStorm defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor WebStorm
Android Studio defaults write wang.jianing.app.OpenInEditor-Lite LiteDefaultEditor Android\ Studio

In particular, if you want to use a custom application as the default, then you can also use this command. Take GitHub Desktop as an example.

defaults write wang.jianing.app.OpenInTerminal-Lite LiteDefaultTerminal GitHub\ Desktop

For Neovim Users

If you select Neovim as your editor, the app will use Kitty as the default terminal. To switch to a different terminal (supported options: Alacritty, WezTerm, and Kitty), update the configuration with the following command. Adjust the Neovim path (/opt/homebrew/bin/nvim in this example) to match your installation:

defaults write wang.jianing.app.OpenInEditor-Lite NeovimCommand "open -na Alacritty --args -e /opt/homebrew/bin/nvim PATH"

Other terminal configurations:

// kitty:
"open -na kitty --args /opt/homebrew/bin/nvim PATH"
// WezTerm:
"open -na wezterm --args start /opt/homebrew/bin/nvim PATH"
// Alacritty:
"open -na Alacritty --args -e /opt/homebrew/bin/nvim PATH"

For Kitty Users

The default launch behavior for kitty is to open a new instance for each command, like the following:

open -na kitty --args --single-instance --instance-group 1 --directory

If you want to customize this behavior, you can run the following command in your terminal. Make sure to replace the open command as what you want:

defaults write wang.jianing.app.OpenInTerminal-Lite KittyCommand "open -na kitty --args --single-instance --instance-group 1 --directory"

2) If you are using Dark Mode

I provided several icons along with the app in the release page.

a. Changing the icon manually

You can right click on the app and select Get Info. Drag the icon to cover the default icon.

b. Changing the icon automatically with Hammerspoon

This procedure is particularly useful for those using the automatic dark/light mode switching feature of macOS.

  1. Install Hammerspoon either by downloading the latest release and dragging it in the /Applications folder, or by using Homebrew:
brew install --cask hammerspoon
  1. Install the fileicon utility to change the app icon programmatically:
brew install fileicon
  1. Create the ~/.hammerspoon/Icons folder and put the icons there

  2. Create the ~/.hammerspoon/init.lua file (if it doesn't already exist) and add the following code:

local function setOpenInEditorLiteIcon(dark)
  -- Change the path in case of a different install location
  local appPath = "/Applications/OpenInEditor-Lite.app"
  -- Change the type accordingly to the icon you want to use (editor, atom, sublime, vscode)
  local iconType = "editor"
  local iconsFolder = hs.fs.currentDir() .. "/Icons"
  local theme = dark and "dark" or "light"
  hs.execute('fileicon set "' .. appPath .. '" "' .. iconsFolder .. "/icon_" .. iconType .. "_" .. theme .. '.icns"', true)
end

local function setOpenInTerminalLiteIcon(dark)
  -- Change the path in case of a different install location
  local appPath = "/Applications/OpenInTerminal-Lite.app"
  -- Change the type accordingly to the icon you want to use (terminal, iterm, hyper)
  local iconType = "terminal"
  local iconsFolder = hs.fs.currentDir() .. "/Icons"
  local theme = dark and "dark" or "light"
  hs.execute('fileicon set "' .. appPath .. '" "' .. iconsFolder .. "/icon_" .. iconType .. "_" .. theme .. '.icns"', true)
end

local function updateIcons()
  darkMode = (hs.settings.get("AppleInterfaceStyle") == "Dark")
  setOpenInEditorLiteIcon(darkMode)
  setOpenInTerminalLiteIcon(darkMode)
end

updateIcons()
hs.settings.watchKey("dark_mode", "AppleInterfaceStyle", function()
  updateIcons()
end)

You can now reload the config file (or restart hammerspoon) and you're done! The icons should automatically update when switching from light to dark mode and vice versa. Don't forget to check the "Launch Hammerspoon at login" option.

3) Open in a new Tab or Window when using iTerm

When you are using iTerm, you can set a default to open a new tab or window. The default is to open a new window.

# Open a new Tab
defaults write com.googlecode.iterm2 OpenFileInNewWindows -bool false
# Open a new Window
defaults write com.googlecode.iterm2 OpenFileInNewWindows -bool true

FAQ ❓

1. Oops, hit Don't Allow button by mistake.

No sweat! Just run the following command in your terminal, and it'll reset the permissions in System Preferences.

# For OpenInTerminal-Lite:
tccutil reset AppleEvents wang.jianing.app.OpenInTerminal-Lite
# For OpenInEditor-Lite:
tccutil reset AppleEvents wang.jianing.app.OpenInEditor-Lite
2. Special characters in the path.

Please do not use backslash \ and double quotes " in the path

3. Why it cannot automatically switch icons in Dark mode

As for OpenInTerminal-Lite, the icon you see in the Finder Toolbar is actually the app icon, not the Finder extension icon. And I haven't found an API yet that lets you swtich the app icon on the fly (got any cool ideas? Do share!).

But hey, good news! Thanks to @MatteoCarnelos's awesome contribution (#126), OpenInTerminal-Lite can now automatically switch icons using Hammerspoon.

4. My custom app doesn't work.

If your custom application doesn't work with the following command, then it's not supported. For example, GitHub Desktop:

open -a GitHub\ Desktop ~/Desktop

Changes 🗒

show all

version 1.2.7

  • Support "open in neovim" for Alacritty, WezTerm, and kitty users.
  • Customize open command for kitty users

version 1.2.6

  • Support Korean
  • For kitty users: open in a signle instance instead of a new one

version 1.2.5

  • Support German

version 1.2.4

  • Support Turkish

version 1.2.3

  • Fix: cannot open path with white space when using Terminal

version 1.2.2

  • Fix: cannot open alacritty
  • Fix: cannot set default editor

version 1.2.1

  • Fix: cannot open alacritty
  • Fix: cannot set default editor

version 1.2.0

  • Support setting custom app (Not all apps support)
  • BigSur-style icon

version 1.1.5

  • fix bug in OpenInEditor-Lite

version 1.1.4

  • Support kitty
  • Open multi-selected files in editors

version 1.1.3

  • Support Italian and Spanish

version 1.1.2

  • Support JetBrains

version 1.1.1

  • Support Russian and Korean
  • Support PhpStorm

version 1.1.0

  • Support CotEditor and MacVim

version 1.0.3

  • Signed the application with the developer account. Bundle ID has changed
  • Support Korean

version 1.0.2

  • Support TextMate
  • Change OpenInEditor-Lite default icon

version 1.0.1

  • Support Visual Studio Code - Insiders

version 1.0.0

  • Support BBEdit
  • Fix: check application folder under home directory

version 0.4.4

  • iTerm will not leave 'cd xxx' in history
  • Fix: icon will not flash in dock

version 0.4.3

  • Fix localization bug

version 0.4.2

  • Support French

version 0.4.1

  • Support Alacritty

version 0.4.0

  • You can set a default to open a new tab or window when using Terminal and Hyper.

version 0.3.0

  • Change name to OpenInTerminal-Lite (OpenInTerminal will come as a more powerful version in the future.)
  • Fix a bug that some special characters in the path would crash the program when opening Hyper.

version 0.2.0

  • Add terminal selector
  • Cancel running clear command when opening iTerm

version 0.1.1

  • Support Hyper
  • Give priority to creating a new tab when opening iTerm

version 0.1.0

  • First release

Special Thanks to ❤️

All the contributors who have helped with the development of OpenInTerminal-Lite.

Reference projects