   ;; Custom modeline segments
   (spaceline-define-segment *buffer-path
     (if buffer-file-name
-        (let ((buffer-path (f-relative buffer-file-name (f-dirname (narf/project-root))))
-              (max-length 50))
-          (if (> (length buffer-path) max-length)
-              (let ((path (reverse (split-string buffer-path "/")))
-                    (output ""))
-                (when (and path (equal "" (car path)))
-                  (setq path (cdr path)))
-                (while (and path (< (length output) (- max-length 4)))
-                  (setq output (concat (car path) "/" output))
-                  (setq path (cdr path)))
-                (when path
-                  (setq output (concat "../" output)))
-                output)
-            buffer-path))
+        (let ((buffer-path (file-relative-name buffer-file-name (narf/project-root)))
+              (max-length (truncate (/ (window-body-width) 1.75))))
+          (concat (projectile-project-name) "/"
+                  (if (> (length buffer-path) max-length)
+                      (let ((path (reverse (split-string buffer-path "/" t)))
+                            (output ""))
+                        (when (and path (equal "" (car path)))
+                          (setq path (cdr path)))
+                        (while (and path (<= (length output) (- max-length 4)))
+                          (setq output (concat (car path) "/" output))
+                          (setq path (cdr path)))
+                        (when path
+                          (setq output (concat "../" output)))
+                        (when (string-suffix-p "/" output)
+                          (setq output (substring output 0 -1)))
+                        output)
+                    buffer-path)))
       "%b")
     :face other-face
     :tight-right t)
 
   (spaceline-define-segment *buffer-modified
-    (propertize
-     (concat (when buffer-file-name
-               (concat
-                (if (buffer-modified-p) "[+]")
-                (if (not (file-exists-p buffer-file-name)) "[!]")))
-             (if buffer-read-only "[RO]"))
-     'face 'mode-line-is-modified)
-    :when (not (string-prefix-p "*" (buffer-name)))
+    (unless (string-prefix-p "*" (buffer-name))
+      (propertize
+       (concat (when buffer-file-name
+                 (concat
+                  (if (buffer-modified-p) "[+]")
+                  (if (not (file-exists-p buffer-file-name)) "[!]")))
+               (if buffer-read-only "[RO]"))
+       'face 'mode-line-is-modified))
     :skip-alternate t
     :tight t)
 

          (cond ((= start 1) ":Top")
                ((>= perc 100) ":Bot")
                (t (format ":%d%%%%" perc))))))
    :tight t)

  (spaceline-define-segment *vc
    "Version control info"
    (substring vc-mode (+ 1 (length (symbol-name (vc-backend buffer-file-name)))))
    :when (and active vc-mode)
    :face other-face
    :tight-right t)


  (spaceline-define-segment *pad
    "Padding, to ensure the mode-line is `powerline-height' pixels tall"
    narf--mode-line-padding
    :tight t)

  (spaceline-compile
   ;; Left side
   '(((*macro-recording *anzu *iedit *evil-substitute *flycheck)
      :skip-alternate t
      :tight t)
     *buffer-path
     *buffer-modified
     *vc)
   ;; Right side
   '(*selection-info
     *major-mode
     *env-version
     *buffer-encoding-abbrev
     (global :when active)
     ("%l/%c" :tight t)
     *buffer-position
     *pad
     ))

  ;; Initialize modeline
  (setq-default mode-line-format '(:eval (spaceline-ml-main))))

(provide 'core-ui)
;;; core-ui.el ends here
