summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
* README: minor changehut2010-05-151-2/+2
* README: rewritehut2010-05-152-115/+48
* fsobject: extended list of container extensionshut2010-05-151-1/+3
* fsobject: remove readlink-attribute, catch OSError in realpath()hut2010-05-152-6/+10
* fsobject: added commenthut2010-05-141-1/+1
* main: fixed --cleanhut2010-05-141-5/+7
* widget.browsercolumn: don't run files when scrolling in right columnhut2010-05-141-1/+1
* fsobject.fsobject: corrected typo and optimized loophut2010-05-141-2/+2
* fsobject.fsobject: applied patcheshut2010-05-143-115/+110
* core/environment: removed useless codehut2010-05-141-4/+0
* TODO: updatehut2010-05-141-0/+1
* fsobject.fsobject: Removed old/unused codehut2010-05-141-7/+1
* gui.ui: don't flush input when console is openhut2010-05-141-2/+2
* fixed #90hut2010-05-132-2/+2
* Added ranger.ext.spawn which runs programs and returns their stdouthut2010-05-132-3/+29
* main: restructured importshut2010-05-131-18/+21
* main: minor change, use relpath_confhut2010-05-131-1/+1
* main: strip off leading "file://" in filenameshut2010-05-131-0/+2
* main: more user friendly crash messageshut2010-05-131-6/+23
* TODO: updatedhut2010-05-121-1/+5
* defaults.options: increased default "scroll_offset" from 2 to 8hut2010-05-101-1/+1
* TODO: updatedhut2010-05-101-3/+13
* main: added commenthut2010-05-101-2/+3
* HACKING: updatehut2010-05-101-8/+3
* all_benchmarks: improvedhut2010-05-102-10/+20
* Makefile: updatedhut2010-05-101-9/+12
* Run python with flag "-O" by defaulthut2010-05-101-1/+1
* fixed "zc" keyhut2010-05-101-10/+10
* defaults.commands: edit current file with ":edit"hut2010-05-101-1/+4
* api.commands: fixed :ehut2010-05-101-3/+4
* close console with <C-D>hut2010-05-101-1/+1
* added <C-P> and <C-N> keys to consolehut2010-05-101-2/+2
* defaults.keys: added hint for "cw"hut2010-05-091-1/+1
* defaults.keys: fixed delete keyhut2010-05-091-1/+1
* fsobject.directory: bugfixhut2010-05-061-1/+1
* ext.human_readable: round(number, 2)hut2010-05-061-1/+1
* fsobject: bugfixhut2010-05-061-3/+3
* fsobject: don't unnecessarily use abspath() in __init__hut2010-05-063-9/+12
* fsobject.fsobject: lazily load mimetypehut2010-05-061-11/+26
* shared.mimetype: optimizationhut2010-05-061-5/+3
* fsobject.fsobject: optimizationshut2010-05-061-30/+44
* fsobject: a couple of optimizationshut2010-05-062-29/+44
* cleanupshut2010-05-059-30/+21
* Added license header to a few fileshut2010-05-044-0/+60
* bm_loader: stuffhut2010-05-031-1/+35
* fsobject: removed obsolete fsobject.type attribute + constantshut2010-05-032-13/+1
* Makefile: added `make bm` to run all benchmarks BMCOUNT timeshut2010-05-031-2/+5
* test: added TODO, skip broken testshut2010-05-034-5/+25
* Makefile: cleaned up, added automatic uninstallhut2010-05-031-58/+57
* ext.accumulator: added commenthut2010-05-021-0/+1
/span> # extract files parameters for `git show` command cmd="echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | $forgit_pager" opts=" $FORGIT_FZF_DEFAULT_OPTS +s +m --tiebreak=index --bind=\"enter:execute($cmd | LESS='-R' less)\" --bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' |${FORGIT_COPY_CMD:-pbcopy})\" $FORGIT_LOG_FZF_OPTS " graph=--graph [[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph= eval "git log $graph --color=always --format='%C(auto)%h%d %s %C(black)%C(bold)%cr' $* $forgit_emojify" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" } # git diff viewer forgit::diff() { forgit::inside_work_tree || return 1 local cmd files opts commit repo [[ $# -ne 0 ]] && { if git rev-parse "$1" -- &>/dev/null ; then commit="$1" && files=("${@:2}") else files=("$@") fi } repo="$(git rev-parse --show-toplevel)" cmd="echo {} |sed 's/.*] //' |xargs -I% git diff --color=always $commit -- '$repo/%' |$forgit_pager" opts=" $FORGIT_FZF_DEFAULT_OPTS +m -0 --bind=\"enter:execute($cmd |LESS='-R' less)\" $FORGIT_DIFF_FZF_OPTS " eval "git diff --name-status $commit -- ${files[*]} | sed -E 's/^(.)[[:space:]]+(.*)$/[\1] \2/'" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" } # git add selector forgit::add() { forgit::inside_work_tree || return 1 # Add files if passed as arguments [[ $# -ne 0 ]] && git add "$@" && return local changed unmerged untracked files opts preview extract changed=$(git config --get-color color.status.changed red) unmerged=$(git config --get-color color.status.unmerged red) untracked=$(git config --get-color color.status.untracked red) # NOTE: paths listed by 'git status -su' mixed with quoted and unquoted style # remove indicators | remove original path for rename case | remove surrounding quotes extract=" sed 's/^.*] //' | sed 's/.* -> //' | sed -e 's/^\\\"//' -e 's/\\\"\$//'" preview=" file=\$(echo {} | $extract) if (git status -s -- \$file | grep '^??') &>/dev/null; then # diff with /dev/null for untracked files git diff --color=always --no-index -- /dev/null \$file | $forgit_pager | sed '2 s/added:/untracked:/' else git diff --color=always -- \$file | $forgit_pager fi" opts=" $FORGIT_FZF_DEFAULT_OPTS -0 -m --nth 2..,.. $FORGIT_ADD_FZF_OPTS " files=$(git -c color.status=always -c status.relativePaths=true status -su | grep -F -e "$changed" -e "$unmerged" -e "$untracked" | sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/' | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | sh -c "$extract") [[ -n "$files" ]] && echo "$files"| tr '\n' '\0' |xargs -0 -I% git add % && git status -su && return echo 'Nothing to add.' } # git reset HEAD (unstage) selector forgit::reset::head() { forgit::inside_work_tree || return 1 local cmd files opts cmd="git diff --cached --color=always -- {} | $forgit_pager " opts=" $FORGIT_FZF_DEFAULT_OPTS -m -0 $FORGIT_RESET_HEAD_FZF_OPTS " files="$(git diff --cached --name-only --relative | FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd")" [[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git reset -q HEAD % && git status --short && return echo 'Nothing to unstage.' } # git checkout-restore selector forgit::restore() { forgit::inside_work_tree || return 1 local cmd files opts cmd="git diff --color=always -- {} | $forgit_pager" opts=" $FORGIT_FZF_DEFAULT_OPTS -m -0 $FORGIT_CHECKOUT_FZF_OPTS " files="$(git ls-files --modified "$(git rev-parse --show-toplevel)"| FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd")" [[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git checkout % && git status --short && return echo 'Nothing to restore.' } # git stash viewer forgit::stash::show() { forgit::inside_work_tree || return 1 local cmd opts cmd="echo {} |cut -d: -f1 |xargs -I% git stash show --color=always --ext-diff % |$forgit_pager" opts=" $FORGIT_FZF_DEFAULT_OPTS +s +m -0 --tiebreak=index --bind=\"enter:execute($cmd | LESS='-R' less)\" $FORGIT_STASH_FZF_OPTS " git stash list | FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" } # git clean selector forgit::clean() { forgit::inside_work_tree || return 1 local files opts opts=" $FORGIT_FZF_DEFAULT_OPTS -m -0 $FORGIT_CLEAN_FZF_OPTS " # Note: Postfix '/' in directory path should be removed. Otherwise the directory itself will not be removed. files=$(git clean -xdfn "$@"| sed 's/^Would remove //' | FZF_DEFAULT_OPTS="$opts" fzf |sed 's#/$##') [[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git clean -xdf '%' && return echo 'Nothing to clean.' } # git ignore generator export FORGIT_GI_REPO_REMOTE=${FORGIT_GI_REPO_REMOTE:-https://github.com/dvcs/gitignore} export FORGIT_GI_REPO_LOCAL=${FORGIT_GI_REPO_LOCAL:-~/.forgit/gi/repos/dvcs/gitignore} export FORGIT_GI_TEMPLATES=${FORGIT_GI_TEMPLATES:-$FORGIT_GI_REPO_LOCAL/templates} forgit::ignore() { [ -d "$FORGIT_GI_REPO_LOCAL" ] || forgit::ignore::update local IFS cmd args cat opts # https://github.com/sharkdp/bat.git hash bat &>/dev/null && cat='bat -l gitignore --color=always' || cat="cat" cmd="$cat $FORGIT_GI_TEMPLATES/{2}{,.gitignore} 2>/dev/null" opts=" $FORGIT_FZF_DEFAULT_OPTS -m --preview-window='right:70%' $FORGIT_IGNORE_FZF_OPTS " # shellcheck disable=SC2206,2207 IFS=$'\n' args=($@) && [[ $# -eq 0 ]] && args=($(forgit::ignore::list | nl -nrn -w4 -s' ' | FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" |awk '{print $2}')) [ ${#args[@]} -eq 0 ] && return 1 # shellcheck disable=SC2068 if hash bat &>/dev/null; then forgit::ignore::get ${args[@]} | bat -l gitignore else forgit::ignore::get ${args[@]} fi } forgit::ignore::update() { if [[ -d "$FORGIT_GI_REPO_LOCAL" ]]; then forgit::info 'Updating gitignore repo...' (cd "$FORGIT_GI_REPO_LOCAL" && git pull --no-rebase --ff) || return 1 else forgit::info 'Initializing gitignore repo...' git clone --depth=1 "$FORGIT_GI_REPO_REMOTE" "$FORGIT_GI_REPO_LOCAL" fi } forgit::ignore::get() { local item filename header for item in "$@"; do if filename=$(find -L "$FORGIT_GI_TEMPLATES" -type f \( -iname "${item}.gitignore" -o -iname "${item}" \) -print -quit); then [[ -z "$filename" ]] && forgit::warn "No gitignore template found for '$item'." && continue header="${filename##*/}" && header="${header%.gitignore}" echo "### $header" && cat "$filename" && echo fi done } forgit::ignore::list() { find "$FORGIT_GI_TEMPLATES" -print |sed -e 's#.gitignore$##' -e 's#.*/##' | sort -fu } forgit::ignore::clean() { setopt localoptions rmstarsilent [[ -d "$FORGIT_GI_REPO_LOCAL" ]] && rm -rf "$FORGIT_GI_REPO_LOCAL" } FORGIT_FZF_DEFAULT_OPTS=" $FZF_DEFAULT_OPTS --ansi --height='80%' --bind='alt-k:preview-up,alt-p:preview-up' --bind='alt-j:preview-down,alt-n:preview-down' --bind='ctrl-r:toggle-all' --bind='ctrl-s:toggle-sort' --bind='?:toggle-preview' --bind='alt-w:toggle-preview-wrap' --preview-window='right:60%' $FORGIT_FZF_DEFAULT_OPTS " # register aliases # shellcheck disable=SC2139 if [[ -z "$FORGIT_NO_ALIASES" ]]; then alias "${forgit_add:-ga}"='forgit::add' alias "${forgit_reset_head:-grh}"='forgit::reset::head' alias "${forgit_log:-glo}"='forgit::log' alias "${forgit_diff:-gd}"='forgit::diff' alias "${forgit_ignore:-gi}"='forgit::ignore' alias "${forgit_restore:-gcf}"='forgit::restore' alias "${forgit_clean:-gclean}"='forgit::clean' alias "${forgit_stash_show:-gss}"='forgit::stash::show' fi