Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
git-scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Hörnquist
git-scripts
Commits
37005fca
Commit
37005fca
authored
3 years ago
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Rewrote git-ls.
parent
32914176
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+4
-1
4 additions, 1 deletion
Makefile
git-ls
+0
-12
0 additions, 12 deletions
git-ls
git-ls.scm
+90
-0
90 additions, 0 deletions
git-ls.scm
with
94 additions
and
13 deletions
Makefile
+
4
−
1
View file @
37005fca
...
@@ -2,5 +2,8 @@
...
@@ -2,5 +2,8 @@
PREFIX
:=
/usr
PREFIX
:=
/usr
install
:
git-ls
:
ln
-s
$(
PWD
)
/git-ls.scm git-ls
install
:
git-ls
cp
git-
*
$(
DESTDIR
)$(
PREFIX
)
/bin/
cp
git-
*
$(
DESTDIR
)$(
PREFIX
)
/bin/
This diff is collapsed.
Click to expand it.
git-ls
deleted
100755 → 0
+
0
−
12
View file @
32914176
#!/bin/bash
Cyan
=
'\e[0;36m'
Normal
=
"
\e
[m"
for
f
in
`
ls
`
;
do
if
[
-f
"
$f
/.git"
]
||
[
-d
"
$f
/.git"
]
;
then
echo
-e
"
$Cyan$f$Normal
"
else
ls
--color
-d
$f
fi
done
| column
This diff is collapsed.
Click to expand it.
git-ls.scm
0 → 100755
+
90
−
0
View file @
37005fca
#
!/usr/bin/guile
\
-e
main
-s
!
#
(
use-modules
(
srfi
srfi-1
)
(
srfi
srfi-71
)
(
ice-9
ftw
)
(
ice-9
regex
)
(
ice-9
popen
))
(
define
cyan
"0;36"
)
(
define
normal
""
)
(
define
error
"1;31"
)
(
define*
(
ansi-escape
color
#
:optional
(
port
#f
))
(
format
port
"\x1b[~am"
color
))
(
define
dir-color
(
cond
((
find
(
lambda
(
s
)
(
string-match
"^di="
s
))
(
string-split
(
or
(
getenv
"LS_COLORS"
)
""
)
#
\
:
))
=>
(
lambda
(
s
)
(
string-drop
s
3
)))
(
else
"01;34"
)))
(
define-public
(
group
list
width
)
(
unless
(
zero?
(
modulo
(
length
list
)
width
))
(
scm-error
'misc-error
"group"
"~a∤~a (~s)"
`
(
,width
,
(
length
list
)
,
list
)
'
()))
(
let
inner
((
list
list
))
(
if
(
null?
list
)
'
()
(
let*
((
row
rest
(
split-at
list
width
)))
(
cons
row
(
inner
rest
))))))
(
define
(
main
args
)
(
define
cols
(
read
(
open-input-pipe
"tput cols"
)))
(
define
dir
(
if
(
<
1
(
length
args
))
(
cadr
args
)
"."
))
(
define
items
(
map
(
lambda
(
pair
)
(
case
(
car
pair
)
((
module
)
(
cons
cyan
(
cdr
pair
)))
((
regular
)
(
catch
'system-error
(
lambda
()
(
case
(
stat:type
(
stat
(
string-append
dir
"/"
(
cdr
pair
))))
((
regular
symlink
block-special
char-special
fifo
socket
unknown
)
(
cons
normal
(
cdr
pair
)))
((
directory
)
(
cons
dir-color
(
cdr
pair
)))))
(
const
(
cons
error
(
cdr
pair
)))))))
(
map
(
lambda
(
file
)
(
if
(
file-exists?
(
string-append
dir
"/"
file
"/.git"
))
(
cons
'module
file
)
(
cons
'regular
file
)))
(
remove
(
lambda
(
filename
)
(
char=?
#\.
(
string-ref
filename
0
)))
(
scandir
dir
)))))
(
let
()
(
define
longest-string
(
apply
max
(
map
string-length
(
map
cdr
items
))))
(
define
items-per-line
(
floor
(
/
cols
(
+
1
longest-string
))))
(
let
((
head
tail-line
(
split-at
items
(
-
(
length
items
)
(
modulo
(
length
items
)
items-per-line
)))))
(
for-each
(
lambda
(
group
)
(
for-each
(
lambda
(
item
)
(
format
#t
"~a~a~a"
(
ansi-escape
(
car
item
))
(
string-pad-right
(
cdr
item
)
(
1+
longest-string
))
(
ansi-escape
normal
)))
group
)
(
newline
))
(
group
head
items-per-line
))
(
for-each
(
lambda
(
item
)
(
format
#t
"~a~a~a"
(
ansi-escape
(
car
item
))
(
string-pad-right
(
cdr
item
)
(
1+
longest-string
))
(
ansi-escape
normal
)))
tail-line
)
(
unless
(
null?
tail-line
)
(
newline
)))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment