Use $CODEX_HOME instead

This commit is contained in:
Daniel Edrisian
2025-08-26 10:04:53 -07:00
parent 0cc82ec1fe
commit 06457825ab
3 changed files with 16 additions and 11 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ codex completion fish
Save frequently used prompts as Markdown files and reuse them quickly from the slash menu.
- Location: Put files in `~/.codex/prompts/` (create the folders if they don’t exist).
- Location: Put files in `$CODEX_HOME/prompts/` (defaults to `~/.codex/prompts/`).
- File type: Only Markdown files with the `.md` extension are recognized.
- Name: The filename without the `.md` extension becomes the slash entry. For a file named `my-prompt.md`, type `/my-prompt`.
- Content: The file contents are sent as your message when you select the item in the slash popup and press Enter.
+9 -6
View File
@@ -1281,12 +1281,15 @@ async fn submission_loop(
let sub_id = sub.id.clone();
// Discover prompts under the default prompts dir (includes content).
let custom_prompts: Vec<CustomPrompt> = tokio::task::spawn_blocking(|| {
let dir = crate::custom_prompts::default_prompts_dir();
crate::custom_prompts::discover_prompts_in(&dir)
})
.await
.unwrap_or_default();
let custom_prompts: Vec<CustomPrompt> =
tokio::task::spawn_blocking(
|| match crate::custom_prompts::default_prompts_dir() {
Some(dir) => crate::custom_prompts::discover_prompts_in(&dir),
None => Vec::new(),
},
)
.await
.unwrap_or_default();
let event = Event {
id: sub_id,
+6 -4
View File
@@ -3,10 +3,12 @@ use std::collections::HashSet;
use std::path::Path;
use std::path::PathBuf;
/// Return the default prompts directory: ~/.codex/prompts based on $HOME.
pub fn default_prompts_dir() -> PathBuf {
let home = std::env::var("HOME").unwrap_or_else(|_| ".".to_string());
PathBuf::from(format!("{home}/.codex/prompts"))
/// Return the default prompts directory: `$CODEX_HOME/prompts`.
/// If `CODEX_HOME` cannot be resolved, returns `None`.
pub fn default_prompts_dir() -> Option<PathBuf> {
crate::config::find_codex_home()
.ok()
.map(|home| home.join("prompts"))
}
/// Discover prompt files in the given directory, returning entries sorted by name.