diff --git a/MANUAL.md b/MANUAL.md index 6af2d144a..9092e342c 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -107,14 +107,15 @@ Basic usage is: $ hledger [OPTIONS] COMMAND [FILTER PATTERNS] hledger first looks for data in a specially-formatted -[journal file](#file-format). You can specify the file with the -f -option or the `LEDGER` environment variable; otherwise hledger assumes it -is a file named `.journal` in your home directory. If the journal file +[journal file](#file-format). You can specify the file with the `-f` +option or the `LEDGER_FILE` environment variable (`LEDGER` is also +supported for backwards compatibility); otherwise hledger assumes it is a +file named `.hledger.journal` in your home directory. If the journal file does not exist, it will be auto-created. To get started, save this [sample file](http://joyful.com/repos/hledger/data/sample.journal) as -`.journal` in your home directory, or just run `hledger add` and enter +`.hledger.journal` in your home directory, or just run `hledger add` and enter some transactions. Now try commands like these: $ hledger add # add some new transactions to the journal file diff --git a/hledger-lib/Hledger/Read.hs b/hledger-lib/Hledger/Read.hs index 2ba716bdc..750674774 100644 --- a/hledger-lib/Hledger/Read.hs +++ b/hledger-lib/Hledger/Read.hs @@ -38,8 +38,9 @@ import System.IO (hGetContents) #endif -journalenvvar = "LEDGER" -timelogenvvar = "TIMELOG" +journalenvvar = "LEDGER_FILE" +journalenvvar2 = "LEDGER" +timelogenvvar = "TIMELOG" journaldefaultfilename = ".journal" timelogdefaultfilename = ".timelog" @@ -111,13 +112,19 @@ emptyJournal = do readJournal :: Maybe String -> String -> IO (Either String Journal) readJournal format s = journalFromPathAndString format "(string)" s --- | Get the user's default journal file path. +-- | Get the user's default journal file path. Like ledger, we look first +-- for the LEDGER_FILE environment variable, and if that does not exist, +-- for the legacy LEDGER environment variable. If neither exists, the path +-- will be ".hledger.journal" in the users's home directory, or if we +-- cannot determine that, in the current directory. myJournalPath :: IO String myJournalPath = getEnv journalenvvar `catch` (\_ -> do - home <- getHomeDirectory `catch` (\_ -> return "") - return $ home journaldefaultfilename) + getEnv journalenvvar2 `catch` + (\_ -> do + home <- getHomeDirectory `catch` (\_ -> return "") + return $ home journaldefaultfilename)) -- | Get the user's default timelog file path. myTimelogPath :: IO String