Hish 0.1.2.0 → 0.1.2.1
raw patch · 5 files changed
+51/−39 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +7/−1
- Hish.cabal +1/−1
- README.md +9/−7
- src/Hish/VCS.hs +16/−7
- src/hish.hs +18/−23
ChangeLog.md view
@@ -27,4 +27,10 @@ ## 0.1.2.0 -- 2015-10-20 * [m] implement supporting of darcs-* [+] check executability of vcs +* [+] check executability of vcs++## 0.1.2.1 -- 2015-10-21++* [m] re-design status symbol+* [m] reset prompt format and color+* [-] turn-off the supporting of darcs
Hish.cabal view
@@ -1,5 +1,5 @@ Name: Hish-Version: 0.1.2.0+Version: 0.1.2.1 Author: Yun-Yan Chi Maintainer: jaiyalas@gmail.com License: BSD3
README.md view
@@ -4,7 +4,7 @@ [](https://en.wikipedia.org/wiki/BSD_licenses) [](http://haskell.org) -Generating a beautiful and useful prompt.+Generating a beautiful and useful prompt. (**Warning**: *darcs* is supported but *turned-off* by default.) ## Features @@ -18,21 +18,23 @@ + will be shortened if too long + [X] support version control system + git (fully supported)- + darcs (darcs has no branch; tracking status is not supported)+ + <del>darcs (darcs has no branch; tracking status is not supported)</del> + [X] show **branch name (git only)**-+ [X] show **index/tree status (git and darcs)**- + *\** - dirty- + *?* - clean *but still having untracked files*- + *#* - clean++ [X] show **index/tree status (git and <del>darcs</del>)**+ + *\ * - clean+ + *?* - clean *but still having untracked files*+ + *#** - dirty non-empty index+ + *\** - dirty with empty index + [X] show **tracking status (git only)** + *+n* - branch is *ahead* by n + *-n* - branch is *behind* by n ### Todo ++ [ ] use *config file*++ [ ] re-design the darcs supporting system + [ ] implement *color theme* + [ ] show *SSH* info-+ [ ] use *config file* + [ ] load *environment variables* ## Installation
src/Hish/VCS.hs view
@@ -22,9 +22,10 @@ vcsBehind :: a -> String -> Maybe String -- | determining the cleanliness of working-tree --- -- * __#__ - /clean/ working directory- -- * __?__ - /clean/ but existing untracked file- -- * __*__ - /dirty/+ -- * __' '__ - /clean/+ -- * __'?'__ - /clean/ (exists untracked file)+ -- * __'#'__ - /dirty/ (non-empty index; ready for commit..)+ -- * __'*'__ - /dirty/ (empty index) vcsCleanliness :: a -> String -> Maybe String vcsCurrentBranch :: a -> String -> Maybe String -- | get command for revealing branch@@ -55,11 +56,19 @@ behind -> Just $ S.replace "behind " "" behind vcsCleanliness _ s = let body = tail $ DL.lines s in case body of- [] -> Just "#"- _ -> let (index,tree) = unzip $ map ((\ (a:b:_)->(a,b)).take 2) body in- if ("" == (filter (/='?') tree))+ [] -> Just ""+ _ -> let (index,tree) = unzip $ map ((\ (a:b:_)->(a,b)).take 2) body in case (filter (/=' ') index, filter (/=' ')tree) of+ -- index == tree == " "+ ("","") -> Just ""+ -- every changes are in index+ (_,"") -> Just "#"+ -- none change is inindex+ ("",_) -> Just "*"+ (idx,tre) -> if ("" == (filter (/='?') (idx++tre)))+ -- left only untracked file then Just "?"- else Just "*"+ -- mix situiation+ else Just "#" vcsCurrentBranch _ = Just . drop 2 . head
src/hish.hs view
@@ -6,25 +6,18 @@ -- for manipulating ANSI code import Data.Monoid (mempty,(<>)) -{- +++++++++++++++++++++++++++++++--- Is this helpful?-import System.Environment (getEnv -- String -> IO String- ,setEnv -- String -> String -> IO ()- ,lookupEnv -- String -> IO (Maybe String)- )-+++++++++++++++++++++++++++++++ -}- _prompt_symbol = ">" _pwdWidth = 60 main :: IO () main = do printUserInfo+ putStr " " printWorkingTree putStr " " -- safePrintVCS VCS.Git- safePrintVCS VCS.Darcs+ -- safePrintVCS VCS.Darcs -- putStr $ applyANSI (_prompt_symbol++" ") $ mempty @@ -33,12 +26,12 @@ printUserInfo = do _ts <- HS.time "%H:%M" putStr $ applyANSI (_ts) $ fgBlackL <> mempty- putStr $ applyANSI "(" $ fgBlackL <> mempty- _un <- HS.uid- case _un of- Nothing -> return ()- Just un -> putStr $ applyANSI (un) $ mempty- putStr $ applyANSI ")" $ fgBlackL <> mempty+ -- putStr $ applyANSI "(" $ fgBlackL <> mempty+ -- _un <- HS.uid+ -- case _un of+ -- Nothing -> return ()+ -- Just un -> putStr $ applyANSI (un) $ mempty+ -- putStr $ applyANSI ")" $ fgBlackL <> mempty -- _hn <- HS.hostname -- case _hn of -- Nothing -> return ()@@ -55,23 +48,25 @@ printVCSInfo vcs = do _br <- HS.branch vcs (_st, _ah, _bh) <- HS.status vcs- putStr $ show vcs- putStr "["+ --putStr $ show vcs+ -- putStr "[" case _br of Just br -> putStr $ applyANSI br $ fgWhiteL <> ESC_Bold <> mempty Nothing -> return () case _st of- Just "*" -> putStr $ applyANSI "*" $ ESC_Bold <> fgRed <> mempty- Just "?" -> putStr $ applyANSI "?" $ ESC_Bold <> fgYellow <> mempty- Just "#" -> putStr $ applyANSI "#" $ ESC_Bold <> fgGreen <> mempty+ Just "*" -> putStr $ applyANSI "*" $ ESC_Bold <> fgYellowL <> mempty+ Just "?" -> putStr $ applyANSI "?" $ ESC_Bold <> fgMagentaL <> mempty+ Just "#" -> putStr $ applyANSI "#" $ ESC_Bold <> fgBlueL <> mempty _ -> putStr "" case _ah of Nothing -> return ()- Just ah -> putStr $ applyANSI (if ah=="" then "" else "+"++ah) $ fgRedL <> mempty+ Just ah -> putStr $ applyANSI (if ah=="" then "" else "+"++ah) $+ fgRedL <> mempty case _bh of Nothing -> return ()- Just bh -> putStr $ applyANSI (if bh=="" then "" else "-"++bh) $ fgGreenL <> mempty- putStr "]"+ Just bh -> putStr $ applyANSI (if bh=="" then "" else "-"++bh) $+ fgGreenL <> mempty+ -- putStr "]" -- safePrintVCS :: (Show a, VCS.VCS a) => a -> IO () safePrintVCS vcs = do