Skip to content
tanazd1-octo edited this page Mar 26, 2026 · 1 revision

cdt

Run commands in any directory without changing your current location.

⚡ Part of termux-miscellaneous


📌 Description

cdt (change directory temporarily) allows you to execute a command in another directory without manually using cd and then coming back.

It keeps your current working directory unchanged.


⚡ Usage

cdt <directory> <command>

🧪 Examples

List files in another directory

cdt /sdcard ls

Run a script in another folder

cdt ~/projects/myapp ./run.sh

Compile code in another directory

cdt ~/code gcc main.c -o main

🧠 What it does

  • Temporarily switches to target directory
  • Executes the given command
  • Returns to original directory automatically

🔧 Behavior

Equivalent to:

(cd <directory> && <command>)

Your current directory is preserved.


📁 Notes

  • Does NOT change your shell’s working directory permanently
  • Works with any valid command
  • Useful for scripting and automation

⚠️ Limitations

  • Command must be valid in the target directory
  • Relative paths inside command depend on target directory

🚀 Tips

Run build without leaving current folder:

cdt ~/project make

Check files anywhere quickly:

cdt /data/data ls

🧩 Related

  • c → custom shell
  • ns → run scripts without shebang
  • x → extract archives
  • tc → multitask commands

Clone this wiki locally