sh 快速查看按修改日期排序的分支的方法。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 快速查看按修改日期排序的分支的方法。相关的知识,希望对你有一定的参考价值。
#!/bin/bash
# Note: this only works in 256bit color terminal
# http://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
rs="\e[0m"
dc="\e[38;5;227m"
cc="\e[38;5;051m"
# Basic output with Y-m-d format
# Requires dateFormat="short"
function sexytime_v1 {
ts=`echo $1 | cut -d' ' -f1`
cm=`echo $1 | cut -d' ' -f2`
#echo -e "\e[38;5;32m$ts\t\e[0m\e[38;5;155m$cm\e[0m"
echo -e "$rs$dc$ts $cc$cm$rs"
}
# Requires dateFormat="iso"
function sexytime_v2 {
ds=`echo "$1" | cut -d' ' -f1`
ts=`echo "$1" | cut -d' ' -f2`
cm=`echo "$1" | cut -d' ' -f4`
echo -e "$rs$dc$ds $ts $cc$cm$rs"
}
# ****************************************************
# GIT log syntax (iso, short, long, local, etc.)
if [ -z "$1" ]; then
git for-each-ref --sort=-committerdate refs/heads --format="%(committerdate:iso) %(refname:short)" | \
while read line; do
sexytime_v2 "$line"
done
else
# Add optional branch name filter
filter="$1"
filter=${filter//\./\\.}
git for-each-ref --sort=-committerdate refs/heads --format="%(committerdate:iso) %(refname:short)" | \
grep "$filter" | \
while read line; do
sexytime_v2 "$line"
done
fi
以上是关于sh 快速查看按修改日期排序的分支的方法。的主要内容,如果未能解决你的问题,请参考以下文章
Bitbucket REST Api:如何通过调用 rest api 按日期 desc 对所有分支进行排序?
DedeCMS文章按发布时间排序方法
按日期快速排序我的tableView
如何按修改日期对 CloudKit 结果进行排序?
在Linux中如何查看文件的修改日期
如何在 python 中获得按创建日期排序的目录列表?