better ~/ handling
This commit is contained in:
parent
112ce4f49c
commit
9a038b4a9b
3 changed files with 12 additions and 6 deletions
|
@ -132,6 +132,14 @@ runPreserveOrder a files = preserveOrder files <$> a files
|
|||
myHomeDir :: IO FilePath
|
||||
myHomeDir = homeDirectory <$> (getUserEntryForID =<< getEffectiveUserID)
|
||||
|
||||
{- Converts paths in the home directory to use ~/ -}
|
||||
relHome :: FilePath -> IO String
|
||||
relHome path = do
|
||||
home <- myHomeDir
|
||||
return $ if dirContains home path
|
||||
then "~/" ++ relPathDirToFile home path
|
||||
else path
|
||||
|
||||
{- Checks if a command is available in PATH. -}
|
||||
inPath :: String -> IO Bool
|
||||
inPath command = getSearchPath >>= anyM indir
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue