mirror of
https://github.com/openai/codex.git
synced 2026-11-10 21:00:47 +00:00
Use $CODEX_HOME instead
This commit is contained in:
+1
-1
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user