Browse Source

Change fish theme

Colin Powell 5 years ago
parent
commit
af46655855

+ 1 - 0
fish/.config/fish/fishfile

@@ -5,3 +5,4 @@ oh-my-fish/plugin-direnv
 joseluisq/gitnow
 fishpkg/fish-git-util
 oh-my-fish/theme-krisleech
+lfiolhais/theme-simple-ass-prompt

+ 6 - 2
fish/.config/fish/functions/bass.fish

@@ -7,7 +7,11 @@ function bass
   end
 
   set -l script_file (mktemp)
-  python (dirname (status -f))/__bass.py $bash_args 3>$script_file
+  if command -v python3 >/dev/null 2>&1
+    command python3 (dirname (status -f))/__bass.py $bash_args 3>$script_file
+  else
+    command python (dirname (status -f))/__bass.py $bash_args 3>$script_file
+  end
   set -l bass_status $status
   if test $bass_status -ne 0
     return $bass_status
@@ -17,7 +21,7 @@ function bass
     cat $script_file
   end
   source $script_file
-  /bin/rm $script_file
+  command rm $script_file
 end
 
 function __bass_usage

+ 8 - 0
fish/.config/fish/functions/fish_greeting.fish

@@ -0,0 +1,8 @@
+# Configure greeting with:
+#   -> set -g simple_ass_prompt_greeting MyGreeting
+
+function fish_greeting
+  set -q simple_ass_prompt_greeting; or set -l simple_ass_prompt_greeting 'Where the hell is Science?!'
+
+  echo $simple_ass_prompt_greeting
+end

+ 108 - 20
fish/.config/fish/functions/fish_prompt.fish

@@ -1,31 +1,119 @@
-# name: Krisleech
-function _git_branch_name
-  echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||')
+# Status Chars
+set __fish_git_prompt_char_dirtystate '!'
+set __fish_git_prompt_char_untrackedfiles '☡'
+set __fish_git_prompt_char_stashstate '↩'
+set __fish_git_prompt_char_cleanstate '✓'
+
+# Display the state of the branch when inside of a git repo
+function __simple_ass_prompt_parse_git_branch_state -d "Display the state of the branch"
+  git update-index --really-refresh -q 1> /dev/null
+
+  # Check for changes to be commited
+  if git_is_touched
+    echo -n "$__fish_git_prompt_char_dirtystate"
+  else
+    echo -n "$__fish_git_prompt_char_cleanstate"
+  end
+
+  # Check for untracked files
+  set -l git_untracked (command git ls-files --others --exclude-standard 2> /dev/null)
+  if [ -n "$git_untracked" ]
+    echo -n "$__fish_git_prompt_char_untrackedfiles"
+  end
+
+  # Check for stashed files
+  if git_is_stashed
+    echo -n "$__fish_git_prompt_char_stashstate"
+  end
+
+  # Check if branch is ahead, behind or diverged of remote
+  git_ahead
+end
+
+# Display current git branch
+function __simple_ass_prompt_git -d "Display the actual git branch"
+  set -l ref
+  set -l std_prompt (prompt_pwd)
+  set -l is_dot_git (string match '*/.git' $std_prompt)
+
+  if git_is_repo; and test -z $is_dot_git
+    printf 'on '
+    set_color purple
+
+    set -l git_branch (command git symbolic-ref --quiet --short HEAD 2> /dev/null; or git rev-parse --short HEAD 2> /dev/null; or echo -n '(unknown)')
+
+    printf '%s ' $git_branch
+
+    set state (__simple_ass_prompt_parse_git_branch_state)
+    set_color 0087ff
+    printf '[%s]' $state
+
+    set_color normal
+  end
+end
+
+# Print current user
+function __simple_ass_prompt_get_user -d "Print the user"
+  if test $USER = 'root'
+    set_color red
+  else
+    set_color d75f00
+  end
+  printf '%s' (whoami)
+end
+
+# Get Machines Hostname
+function __simple_ass_prompt_get_host -d "Get Hostname"
+  if test $SSH_TTY
+    tput bold
+    set_color red
+  else
+    set_color af8700
+  end
+  printf '%s' (hostname|cut -d . -f 1)
 end
 
-function _is_git_dirty
-  echo (command git status -s --ignore-submodules=dirty 2> /dev/null)
+# Get Project Working Directory
+function __simple_ass_prompt_pwd -d "Get PWD"
+  set_color $fish_color_cwd
+  printf '%s ' (prompt_pwd)
 end
 
+# Simple-ass-prompt
 function fish_prompt
-  set -l cyan (set_color -o cyan)
-  set -l yellow (set_color -o yellow)
-  set -l red (set_color -o red)
-  set -l blue (set_color -o blue)
-  set -l green (set_color -o green)
-  set -l normal (set_color normal)
+  set -l code $status
+
+  # Logged in user
+  __simple_ass_prompt_get_user
+  set_color normal
+  printf ' at '
+
+  # Machine logged in to
+  __simple_ass_prompt_get_host
+  set_color normal
+  printf ' in '
+
+  # Path
+  __simple_ass_prompt_pwd
+  set_color normal
 
-  set -l cwd $cyan(basename (prompt_pwd))
+  # Git info
+  __simple_ass_prompt_git
 
-  if [ (_git_branch_name) ]
-    set -l git_branch (_git_branch_name)
-    set git_info "$green$git_branch "
+  # Line 2
+  echo
+  if test -e "Cargo.toml"
+    printf "(rust:%s) " (set_color red)(rustup show | tail -n 3 | head -n 1 |  cut -d '-' -f 1)(set_color normal)
+  end
+
+  if test $VIRTUAL_ENV
+    printf "(python:%s) " (set_color blue)(basename $VIRTUAL_ENV)(set_color normal)
+  end
 
-    if [ (_is_git_dirty) ]
-      set -l dirty "$yellow✗"
-      set git_info "$git_info$dirty"
-    end
+  if test $code -eq 127
+    set_color red
   end
 
-  echo -n -s $cwd $red '|' $git_info $normal ⇒ ' ' $normal
+  printf '↪ '
+  set_color normal
 end

+ 3 - 0
fish/.config/fish/functions/fish_right_prompt.fish

@@ -0,0 +1,3 @@
+function fish_right_prompt
+
+end

+ 4 - 0
fish/.config/fish/functions/fish_title.fish

@@ -0,0 +1,4 @@
+function fish_title
+  # Customize the title bar of the terminal window.
+  printf '%s' (prompt_pwd)
+end