From 3e6f21dad9a081b5fc37179af404646667064423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 25 Jul 2021 14:42:19 -0700 Subject: [PATCH 1/5] Create loc.nu --- with_externals/loc.nu | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 with_externals/loc.nu diff --git a/with_externals/loc.nu b/with_externals/loc.nu new file mode 100644 index 0000000..41524ca --- /dev/null +++ b/with_externals/loc.nu @@ -0,0 +1,13 @@ +# This script requires that `tokei` be installed and available! + +# Count lines of code in a project. +def "loc" [ + ...rest # args to pass to tokei +] { + tokei -o json $rest | + from json | + pivot | + rename lang lines | + insert files { get lines.reports | length } | + select lang files lines.code lines.comments lines.blanks +} From 39a6b960c5bf6093b3afe1d43aa2fb5eeccee26a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 25 Jul 2021 14:46:02 -0700 Subject: [PATCH 2/5] parse dates into datetimes This makes it so nu treats the dates as actual dates, and displays them accordingly. --- git/git_branch_age.nu | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/git/git_branch_age.nu b/git/git_branch_age.nu index 43dd136..fcd477e 100755 --- a/git/git_branch_age.nu +++ b/git/git_branch_age.nu @@ -1,6 +1,15 @@ # Creates a table listing the branches of a git repository and the day of the last commit -git branch | lines | str substring 2, | wrap name | insert "last commit" { - get name | each { - git show $it --no-patch --format=%as - } -} | sort-by "last commit" +def "git age" [] { + git branch | + lines | + str substring 2, | + wrap name | + insert date { + get name | + each { + git show $it --no-patch --format=%as | str to-datetime + } + } | + sort-by date +} + From 8dd86215ed50d800b341c8859bfa3f1d8d26d4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 25 Jul 2021 14:48:06 -0700 Subject: [PATCH 3/5] Update git_branch_age.nu --- git/git_branch_age.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_branch_age.nu b/git/git_branch_age.nu index fcd477e..d26fa17 100755 --- a/git/git_branch_age.nu +++ b/git/git_branch_age.nu @@ -4,7 +4,7 @@ def "git age" [] { lines | str substring 2, | wrap name | - insert date { + insert last_commit { get name | each { git show $it --no-patch --format=%as | str to-datetime From aba60c333c4ac05510baf074655a99adc426dbc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 25 Jul 2021 14:48:44 -0700 Subject: [PATCH 4/5] Update git_branch_age.nu --- git/git_branch_age.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/git_branch_age.nu b/git/git_branch_age.nu index d26fa17..9e30bf6 100755 --- a/git/git_branch_age.nu +++ b/git/git_branch_age.nu @@ -10,6 +10,6 @@ def "git age" [] { git show $it --no-patch --format=%as | str to-datetime } } | - sort-by date + sort-by last_commit } From 43756d727a1d430cdcb8421ebba935882479e8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 25 Jul 2021 14:53:11 -0700 Subject: [PATCH 5/5] readme for with_externals --- with_externals/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 with_externals/README.md diff --git a/with_externals/README.md b/with_externals/README.md new file mode 100644 index 0000000..32559fb --- /dev/null +++ b/with_externals/README.md @@ -0,0 +1,7 @@ +# With Externals + +This folder includes various nushell scripts that require installing an external program in order to work. + +### Contributing + +Please include the name of the program and, if possible, basic installation instructions, as part of your script.