Selaa lähdekoodia

[fish] Clean up fish config files

Colin Powell 4 vuotta sitten
vanhempi
commit
b25cfd6ccd

+ 33 - 23
fish/.config/fish/conf.d/gitnow.fish

@@ -1,13 +1,13 @@
 # GitNow — Speed up your Git workflow. 🐠
 # https://github.com/joseluisq/gitnow
 
-function __gitnow_install -e paket_install
+function __gitnow_install -e gitnow_install
     echo (gitnow -v)" is installed and ready to use!"
     echo "Just run the `gitnow` command if you want explore the API."
 end
 
-function __gitnow_uninstall -e paket_uninstall
-    echo "GitNow is uninstalled successfully."
+function __gitnow_uninstall -e gitnow_uninstall
+    echo "GitNow was uninstalled successfully."
 end
 
 function gitnow -d "Gitnow: Speed up your Git workflow. 🐠" -a xversion
@@ -374,8 +374,11 @@ function move -d "GitNow: Switch from current branch to another but stashing unc
 
     # Fetch branch from remote
     if test -n "$v_upstream"
-        command git fetch (__gitnow_current_remote) $v_branch
-        set v_fetched 1
+        set -l v_remote (__gitnow_current_remote)
+        command git fetch $v_remote $v_branch:refs/remotes/$v_remote/$v_branch
+        command git checkout --track $v_remote/$v_branch
+        commandline -f repaint
+        return
     end
 
     set -l v_found (__gitnow_check_if_branch_exist $v_branch)
@@ -424,28 +427,35 @@ function logs -d "Gitnow: Shows logs in a fancy way"
         return
     end
 
-    set -l args HEAD
+    set -l v_max_commits "80"
+    set -l v_args
+
+    for v in $argv
+        switch $v
+            case -h --help
+                echo "NAME"
+                echo "      Gitnow: logs - Show logs in a fancy way (first $v_max_commits commits by default)"
+                echo "EXAMPLES"
+                echo "      logs [git log options]"
+                echo "EXTRA OPTIONS:"
+                echo "      -h, --help      Show information about the options for this command"
+                return
+            case -\*
+            case '*'
+                set v_args $argv
+                break
+        end
+    end
 
-    if test -n "$argv"
-        set args $argv
+    if test -n "$v_args"
+        set v_max_commits
+    else
+        set v_max_commits "-$v_max_commits"
     end
 
-    LC_ALL=C command git log $args --color --graph \
-        --pretty=format:"%Cred%h%C(reset) -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%C(reset) %C(brightmagenta dim)###%GK###%C(reset)%C(brightblack)@@%G?@@%C(reset)" --abbrev-commit \
-        | LC_ALL=C command sed -E 's/@@@@//' \
-        | LC_ALL=C command sed -E 's/@@([^"]*)@@/ (\1)/' \
-        | LC_ALL=C command sed -E "s/###([^\"]*)###([^\"]*)\(G\)/"(command tput setaf 2)"\1/" \
-        | LC_ALL=C command sed -E 's/###([^"]*)###/\1/' \
-        | LC_ALL=C command sed -E 's/\(B\)/(bad signature)/' \
-        | LC_ALL=C command sed -E 's/\(U\)/(good unknown validity signature)/' \
-        | LC_ALL=C command sed -E 's/\(X\)/(good expired signature)/' \
-        | LC_ALL=C command sed -E 's/\(Y\)/(good signature with expired key)/' \
-        | LC_ALL=C command sed -E 's/\(R\)/(good signature with revoked key)/' \
-        | LC_ALL=C command sed -E 's/\(E\)/(No checked signature)/' \
-        | LC_ALL=C command sed -E 's/\(N\)//' \
+    LC_ALL=C command git log $v_max_commits $v_args --color --graph \
+        --pretty=format:"%C(red)%h%C(reset)%C(yellow)%d%Creset %s %C(green italic)(%cr)%C(reset) %C(blue)%an%C(reset) %C(white dim)%GK %C(reset)" --abbrev-commit \
         | command less -R
-
-    commandline -f repaint
 end
 
 function tag -d "Gitnow: Tag commits following Semver"

+ 22 - 8
fish/.config/fish/conf.d/gitnow_config.fish

@@ -1,18 +1,32 @@
 # GitNow — Speed up your Git workflow. 🐠
 # https://github.com/joseluisq/gitnow
 
-set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
-set -q fish_config; or set -g fish_config $XDG_CONFIG_HOME/fish
+set -g gitnow_version 2.8.0
+
+if set -q __fish_config_dir
+    set -g fish_config "$__fish_config_dir"
+else
+    set -q XDG_CONFIG_HOME
+        and set -g fish_config "$XDG_CONFIG_HOME/fish"
+        or set -g fish_config "~/.config/fish"
+end
+
 set -q fish_snippets; or set -g fish_snippets "$fish_config/conf.d"
 set -q fish_functions; or set -g fish_functions "$fish_config/functions"
 set -q fish_completions; or set -g fish_completions "$fish_config/completions"
 set -q GITNOW_CONFIG_FILE; or set -g GITNOW_CONFIG_FILE ~/.gitnow
 
-set -g gitnow_version 2.6.0
-
-source "$fish_functions/__gitnow_functions.fish"
-source "$fish_functions/__gitnow_manual.fish"
-source "$fish_functions/__gitnow_config_file.fish"
-source "$fish_completions/__gitnow_completions.fish"
+if functions -q __fundle_plugins_dir
+    set -l fundledir (__fundle_plugins_dir)
+    source "$fundledir/joseluisq/gitnow/functions/__gitnow_functions.fish"
+    source "$fundledir/joseluisq/gitnow/functions/__gitnow_manual.fish"
+    source "$fundledir/joseluisq/gitnow/functions/__gitnow_config_file.fish"
+    source "$fundledir/joseluisq/gitnow/completions/__gitnow_completions.fish"
+else
+    source "$fish_functions/__gitnow_functions.fish"
+    source "$fish_functions/__gitnow_manual.fish"
+    source "$fish_functions/__gitnow_config_file.fish"
+    source "$fish_completions/__gitnow_completions.fish"
+end
 
 __gitnow_read_config

+ 0 - 8
fish/.config/fish/conf.d/plugin-direnv_init.fish

@@ -1,8 +0,0 @@
-if type -q direnv
-  function __direnv_export_eval --on-variable PWD
-    status --is-command-substitution; and return
-    eval (direnv export fish)
-  end
-else
-  echo "Install direnv first! Check http://direnv.net" 2>&1
-end

+ 35 - 35
fish/.config/fish/conf.d/z.fish

@@ -1,63 +1,63 @@
 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"
+    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"
+    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"
+    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
+    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
+    function $ZO_CMD -d "open target dir"
+        __z -d $argv
+    end
 end
 
 if not set -q Z_EXCLUDE
-  set -U Z_EXCLUDE "^$HOME\$"
+    set -U Z_EXCLUDE "^$HOME\$"
 else if contains $HOME $Z_EXCLUDE
-  # Workaround: migrate old default values to a regex (see #90).
-  set Z_EXCLUDE (string replace -r -- "^$HOME\$" '^'$HOME'$$' $Z_EXCLUDE)
+    # Workaround: migrate old default values to a regex (see #90).
+    set Z_EXCLUDE (string replace -r -- "^$HOME\$" '^'$HOME'$$' $Z_EXCLUDE)
 end
 
 # Setup completions once first
 __z_complete
 
 function __z_on_variable_pwd --on-variable PWD
-  __z_add
+    __z_add
 end
 
 function __z_uninstall --on-event z_uninstall
-  functions -e __z_on_variable_pwd
-  functions -e $Z_CMD
-  functions -e $ZO_CMD
-
-  if test ! -z "$Z_DATA"
-      printf "To completely erase z's data, remove:\n" > /dev/stderr
-      printf "%s\n" "$Z_DATA" > /dev/stderr
-  end
-
-  set -e Z_CMD
-  set -e ZO_CMD
-  set -e Z_DATA
-  set -e Z_EXCLUDE
-end
+    functions -e __z_on_variable_pwd
+    functions -e $Z_CMD
+    functions -e $ZO_CMD
+
+    if test ! -z "$Z_DATA"
+        printf "To completely erase z's data, remove:\n" >/dev/stderr
+        printf "%s\n" "$Z_DATA" >/dev/stderr
+    end
+
+    set -e Z_CMD
+    set -e ZO_CMD
+    set -e Z_DATA
+    set -e Z_EXCLUDE
+end

+ 2 - 0
fish/.config/fish/config.fish

@@ -10,5 +10,7 @@ set -gx PATH ~/.asdf/installs/rust/latest/bin $PATH
 fzf_key_bindings
 set -gx EDITOR vi
 set -gx XDG_RUNTIME_DIR /run/user/(id -u)
+set -gx FZF_LEGACY_KEYBINDS 0
+set -gx FZF_COMPLETE 1
 direnv hook fish | source
 alias ls=exa

+ 2 - 0
fish/.config/fish/fish_variables

@@ -1,6 +1,8 @@
 # This file contains fish universal variable definitions.
 # VERSION: 3.0
+SETUVAR FZF_COMPLETE:3
 SETUVAR FZF_DEFAULT_OPTS:\x2d\x2dheight\x2040\x25
+SETUVAR FZF_DISABLE_KEYBINDINGS:0
 SETUVAR FZF_LEGACY_KEYBINDINGS:0
 SETUVAR FZF_PREVIEW_DIR_CMD:ls
 SETUVAR FZF_PREVIEW_FILE_CMD:head\x20\x2dn\x2010

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

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

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

@@ -8,9 +8,9 @@ function bass
 
   set -l script_file (mktemp)
   if command -v python3 >/dev/null 2>&1
-    command python3 (dirname (status -f))/__bass.py $bash_args 3>$script_file
+    command python3 -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
   else
-    command python (dirname (status -f))/__bass.py $bash_args 3>$script_file
+    command python -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
   end
   set -l bass_status $status
   if test $bass_status -ne 0

+ 1 - 1
fish/.config/fish/functions/fzf_key_bindings.fish

@@ -1 +1 @@
-/usr/home/powellc/.fzf/shell/key-bindings.fish
+/home/powellc/.fzf/shell/key-bindings.fish