فهرست منبع

[fish] Update gitnow and some new aliases

Colin Powell 4 سال پیش
والد
کامیت
4dbb9f6dda

+ 201 - 3
fish/.config/fish/conf.d/gitnow.fish

@@ -81,7 +81,7 @@ function show -d "Gitnow: Show commit detail objects"
     if test $len -gt 0
         command git show $argv
     else
-        command git show --compact-summary HEAD
+        command git show --compact-summary --patch HEAD
     end
 
     commandline -f repaint
@@ -125,7 +125,7 @@ function commit-all -d "Gitnow: Add and commit all changes to the repository"
     commit .
 end
 
-function pull -d "Gitnow: Pull changes from remote server but saving uncommitted changes"
+function pull -d "Gitnow: Pull changes from remote server but stashing uncommitted changes"
     if not __gitnow_is_git_repository
         __gitnow_msg_not_valid_repository "pull"
         return
@@ -271,6 +271,16 @@ function move -d "GitNow: Switch from current branch to another but stashing unc
             case -nu -un
                 set v_upstream "-u"
                 set v_no_apply_stash "-n"
+            case -h --help
+                echo "NAME"
+                echo "      Gitnow: move - Switch from current branch to another but stashing uncommitted changes"
+                echo "EXAMPLES"
+                echo "      move <branch to switch to>"
+                echo "OPTIONS:"
+                echo "      -n --no-apply-stash     Switch to a local branch but without applying current stash"
+                echo "      -u --upstream           Fetch a remote branch and switch to it applying current stash. It can be combined with --no-apply-stash"
+                echo "      -h --help               Show information about the options for this command"
+                return
             case -\*
             case '*'
                 set v_branch $v
@@ -345,7 +355,195 @@ function logs -d "Gitnow: Shows logs in a fancy way"
         set args $argv
     end
 
-    command git log $args --color --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit | command less -r
+    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 \
+        | command sed -E 's/@@@@//' \
+        | command sed -E 's/@@([^"]*)@@/ (\1)/' \
+        | command sed -E "s/###([^\"]*)###([^\"]*)\(G\)/"(command tput setaf 2)"\1/" \
+        | command sed -E 's/###([^"]*)###/\1/' \
+        | command sed -E 's/\(B\)/(bad signature)/' \
+        | command sed -E 's/\(U\)/(good unknown validity signature)/' \
+        | command sed -E 's/\(X\)/(good expired signature)/' \
+        | command sed -E 's/\(Y\)/(good signature with expired key)/' \
+        | command sed -E 's/\(R\)/(good signature with revoked key)/' \
+        | command sed -E 's/\(E\)/(No checked signature)/' \
+        | command sed -E 's/\(N\)//' \
+        | command less -R
+
+    commandline -f repaint
+end
+
+function tag -d "Gitnow: Tag commits following Semver"
+    if not __gitnow_is_git_repository
+        __gitnow_msg_not_valid_repository "tag"
+        return
+    end
+
+    set -l v_major
+    set -l v_minor
+    set -l v_patch
+    set -l v_premajor
+    set -l v_preminor
+    set -l v_prepatch
+
+    # NOTE: this function only gets the latest *Semver release version* but no suffixed ones or others
+    set -l v_latest (__gitnow_get_latest_semver_release_tag)
+
+    for v in $argv
+        switch $v
+            case -x --major
+                set v_major $v
+            case -y --minor
+                set v_minor $v
+            case -z --patch
+                set v_patch $v
+
+            # TODO: pre-release versions are not supported yet
+            # case -a --premajor
+            #     set v_premajor $v
+            # case -b --preminor
+            #     set v_preminor $v
+            # case -c --prepatch
+            #     set v_prepatch $v
+
+            case -l --latest
+                if not test -n "$v_latest"
+                    echo "There is no any tag created yet."
+                else
+                    echo $v_latest
+                end
+
+                return
+            case -h --help
+                echo "NAME"
+                echo "      Gitnow: tag - List or tag commits following The Semantic Versioning 2.0.0 (Semver) [1]"
+                echo "      [1] https://semver.org/"
+                echo "EXAMPLES"
+                echo "      List tags: tag"
+                echo "      Custom tag: tag <my tag name>"
+                echo "      Semver tag: tag --major"
+                echo "OPTIONS:"
+                echo "      Without options all tags are listed in a lexicographic order and tag names are treated as versions"
+                echo "      -x --major         Tag auto-incrementing a major version number"
+                echo "      -y --minor         Tag auto-incrementing a minor version number"
+                echo "      -z --patch         Tag auto-incrementing a patch version number"
+                echo "      -l --latest        Show only the latest Semver release tag version (no suffixed ones or others)"
+                echo "      -h --help          Show information about the options for this command"
+
+                # TODO: pre-release versions are not supported yet
+                # echo "      -a --premajor      Tag auto-incrementing a premajor version number"
+                # echo "      -b --preminor      Tag auto-incrementing a preminor version number"
+                # echo "      -c --prepatch      Tag auto-incrementing a prepatch version number"
+
+                return
+            case -\*
+            case '*'
+                return
+        end
+    end
+
+    # List all tags in a lexicographic order and treating tag names as versions
+    if test -z $argv
+        __gitnow_get_tags_ordered
+        return
+    end
+
+    # Major version tags
+    if test -n "$v_major"
+        if not test -n "$v_latest"
+            command git tag v1.0.0
+            echo "First major tag \"v1.0.0\" was created."
+            return
+        else
+            set -l vstr (__gitnow_get_valid_semver_release_value $v_latest)
+
+            # Validate Semver format before to proceed
+            if not test -n "$vstr"
+                echo "The latest tag \"$v_latest\" has no a valid Semver format."
+                return
+            end
+
+            set -l x (echo $vstr | awk -F '.' '{print $1}')
+            set -l prefix (echo $v_latest | awk -F "$vstr" '{print $1}')
+            set x (__gitnow_increment_number $x)
+            set -l xyz "$prefix$x.0.0"
+
+            command git tag $xyz
+            echo "Major tag \"$xyz\" was created."
+            return
+        end
+    end
+
+
+    # Minor version tags
+    if test -n "$v_minor"
+        if not test -n "$v_latest"
+            command git tag v0.1.0
+            echo "First minor tag \"v0.1.0\" was created."
+            return
+        else
+            set -l vstr (__gitnow_get_valid_semver_release_value $v_latest)
+
+            # Validate Semver format before to proceed
+            if not test -n "$vstr"
+                echo "The latest tag \"$v_latest\" has no a valid Semver format."
+                return
+            end
+
+            set -l x (echo $vstr | awk -F '.' '{print $1}')
+            set -l y (echo $vstr | awk -F '.' '{print $2}')
+            set -l prefix (echo $v_latest | awk -F "$vstr" '{print $1}')
+            set y (__gitnow_increment_number $y)
+            set -l xyz "$prefix$x.$y.0"
+
+            command git tag $xyz
+            echo "Minor tag \"$xyz\" was created."
+            return
+        end
+    end
+
+
+    # Patch version tags
+    if test -n "$v_patch"
+        if not test -n "$v_latest"
+            command git tag v0.0.1
+            echo "First patch tag \"v0.1.0\" was created."
+            return
+        else
+            set -l vstr (__gitnow_get_valid_semver_release_value $v_latest)
+
+            # Validate Semver format before to proceed
+            if not test -n "$vstr"
+                echo "The latest tag \"$v_latest\" has no a valid Semver format."
+                return
+            end
+
+            set -l x (echo $vstr | awk -F '.' '{print $1}')
+            set -l y (echo $vstr | awk -F '.' '{print $2}')
+            set -l z (echo $vstr | awk -F '.' '{print $3}')
+            set -l s (echo $z | awk -F '-' '{print $1}')
+
+            if __gitnow_is_number $s
+                set -l prefix (echo $v_latest | awk -F "$vstr" '{print $1}')
+                set s (__gitnow_increment_number $s)
+                set -l xyz "$prefix$x.$y.$s"
+
+                command git tag $xyz
+                echo "Patch tag \"$xyz\" was created."
+            else
+                echo "No patch version found."
+            end
+
+            return
+        end
+    end
+
+
+    # TODO: pre-release versions are not supported yet
+    # TODO: Premajor version tags
+    # TODO: Preminor version tags
+    # TODO: Prepatch version tags
+
 
     commandline -f repaint
 end

+ 3 - 1
fish/.config/fish/conf.d/gitnow_config.fish

@@ -5,12 +5,14 @@ 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 -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.4.0
+set -g gitnow_version 2.5.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"
 
 __gitnow_read_config

+ 4 - 1
fish/.config/fish/conf.d/z.fish

@@ -33,7 +33,10 @@ if test ! -z $ZO_CMD
 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)
 end
 
 # Setup completions once first

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

@@ -6,7 +6,9 @@ set -gx PATH ~/.emacs.d/bin $PATH
 set -gx GIT_CU_DIR ~/src
 #set -gx PATH ~/.fzf/bin $PATH
 set -gx PATH ~/.local/bin $PATH
+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)
 direnv hook fish | source
+alias ls=exa

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

@@ -11,7 +11,7 @@ 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 Z_EXCLUDE:\x5e/home/powellc\x24
 SETUVAR __done_min_cmd_duration:5000
 SETUVAR __fish_init_2_39_8:\x1d
 SETUVAR __fish_init_2_3_0:\x1d

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

@@ -1,4 +1,4 @@
 #!/usr/bin/env fish
 function djrun
-	django-admin runserver
+	django-admin runserver 0.0.0.0:8000
 end

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

@@ -1,3 +1,3 @@
 function ec
-	emacsclient --nw
+emacsclient -cnq
 end