Browse Source

Add z to fish

Colin Powell 5 years ago
parent
commit
683b66889b
3 changed files with 50 additions and 1 deletions
  1. 44 0
      fish/.config/fish/conf.d/z.fish
  2. 5 1
      fish/.config/fish/fish_variables
  3. 1 0
      fish/.config/fish/fishfile

+ 44 - 0
fish/.config/fish/conf.d/z.fish

@@ -0,0 +1,44 @@
+if test -z "$Z_DATA"
+  if test -z "$XDG_DATA_HOME"
+    set -U Z_DATA_DIR "$HOME/.local/share/z"
+  else 
+    set -U Z_DATA_DIR "$XDG_DATA_HOME/z"
+  end
+  set -U Z_DATA "$Z_DATA_DIR/data"
+end
+
+if test ! -e "$Z_DATA"
+  if test ! -e "$Z_DATA_DIR"
+    mkdir -p -m 700 "$Z_DATA_DIR"  
+  end
+  touch "$Z_DATA"
+end
+
+if test -z "$Z_CMD"
+  set -U Z_CMD "z"
+end
+
+set -U ZO_CMD "$Z_CMD"o
+
+if test ! -z $Z_CMD
+  function $Z_CMD -d "jump around"
+    __z $argv
+  end
+end
+
+if test ! -z $ZO_CMD
+  function $ZO_CMD -d "open target dir"
+    __z -d $argv
+  end
+end
+
+if not set -q Z_EXCLUDE
+  set -U Z_EXCLUDE $HOME
+end
+
+# Setup completions once first
+__z_complete
+
+function __z_on_variable_pwd --on-variable PWD
+  __z_add
+end

+ 5 - 1
fish/.config/fish/fish_variables

@@ -7,7 +7,11 @@ SETUVAR FZF_PREVIEW_FILE_CMD:head\x20\x2dn\x2010
 SETUVAR FZF_TMUX_HEIGHT:40\x25
 SETUVAR --export TERM:screen\x2d256color
 SETUVAR THEME_EDEN_PROMPT_CHAR:\u00bb
-SETUVAR Z_DATA_DIR:/Users/colinpowell/\x2elocal/share/z
+SETUVAR ZO_CMD:zo
+SETUVAR Z_CMD:z
+SETUVAR Z_DATA:/home/powellc/\x2elocal/share/z/data
+SETUVAR Z_DATA_DIR:/home/powellc/\x2elocal/share/z
+SETUVAR Z_EXCLUDE:/home/powellc
 SETUVAR __done_min_cmd_duration:5000
 SETUVAR __fish_init_2_39_8:\x1d
 SETUVAR __fish_init_2_3_0:\x1d

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

@@ -6,3 +6,4 @@ joseluisq/gitnow
 fishpkg/fish-git-util
 oh-my-fish/theme-krisleech
 lfiolhais/theme-simple-ass-prompt
+jethrokuan/z