Skip to main content
  1. Projects/


·455 words·3 mins
Detail codes on GitHub

Introduction #

Inf is a brief script designed to simplify the process of creating and opening a new file using the CLI in popular IDEs like VSCode, IntelliJ, Sublime Text, and more.

When working on a project, the task of creating and opening a file can be a bit tedious. That’s why I developed this script, to bring you a more convenient experience.
Almost all IDEs provide a CLI tool for creating a new file, but when I try to make and open a new one, it only works if the file or directory already exists.

With Inf, you can create and open a new file smoothly even if the file or directory does not exist! 🚀

Supported IDEs and Editors #

IDEs and editors that I tested by myself are as follows:

Code Snippet #

It only accepts the IDEs installed in “/usr/local/bin”. ⚠️


# Usage: inf <ide> "<file>" | "<directory>"
# Example: inf idea "src/main/java/com/example/" 
#          inf code "src/main/java/com/example"

# Declare the first argument as the IDE.
# Declare the second argument as the target file or directory.

# Check if the target IDE is valid.
## Currently, It accept IDE installed in "/usr/local/bin" only!
if [ ! -x "/usr/local/bin/$IDE" ]; then
  echo "$IDE - IDE could not be found"
  exit 1

# Get the directory name to create the file in.
dir=$(dirname -- "$TARGET")

# If the directory doesn't exist, make it.
if [ ! -d "$dir" ]; then
  mkdir -p "$dir"

# If the file doesn't exist, create it.
if [ ! -f "$TARGET" ]; then
  touch "$TARGET"

# Open the file in the specified IDE.
"$(command -v $IDE)" "$TARGET"

Installation #

Before installing it, please check that the ‘inf’ command already exists in your system.

$ command -v inf || echo "Not exist"

# if the 'inf' command doesn't exist, you can install it.
$ git clone
$ cd inf
$ sudo chmod 755
$ sudo cp /usr/local/bin/inf

Usage #

You don’t need double quotation marks for the file or directory path if no special character exists.
However, double quotation marks must be used if the path contains special characters. 🥸

# default usage
$ inf [ide] "[file]" | [directory]

$ inf idea "src/main/java/com/example/"

# Also you can use the alias in your shell configuration file. (e.g. .bashrc, .zshrc)
$ alias infi="inf idea"
$ alias infc="inf code"
$ alias infs="inf subl"

$ infi "src/main/java/com/example/"

Conclusion #

I hope this script will help you create a new file more conveniently. 👋
If you have any questions or suggestions, please feel free to contact me.

Thank you for reading! 🙏