shellutils.scm 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 Matthew Jordan <matthewjordandevops@yandex.com>
  3. ;;; Copyright © 2016, 2017 Alex Griffin <a@ajgrf.com>
  4. ;;; Copyright © 2016 Christopher Baines <mail@cbaines.net>
  5. ;;; Copyright © 2017 Stefan Reichör <stefan@xsteve.at>
  6. ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  7. ;;; Copyright © 2018 Benjamin Slade <slade@jnanam.net>
  8. ;;; Copyright © 2019 Collin J. Doering <collin@rekahsoft.ca>
  9. ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
  10. ;;; Copyright © 2020 aecepoglu <aecepoglu@fastmail.fm>
  11. ;;; Copyright © 2020 Dion Mendel <guix@dm9.info>
  12. ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
  13. ;;; Copyright © 2021 Alexandr Vityazev <avityazev@posteo.org>
  14. ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
  15. ;;;
  16. ;;; This file is part of GNU Guix.
  17. ;;;
  18. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  19. ;;; under the terms of the GNU General Public License as published by
  20. ;;; the Free Software Foundation; either version 3 of the License, or (at
  21. ;;; your option) any later version.
  22. ;;;
  23. ;;; GNU Guix is distributed in the hope that it will be useful, but
  24. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  25. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. ;;; GNU General Public License for more details.
  27. ;;;
  28. ;;; You should have received a copy of the GNU General Public License
  29. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  30. (define-module (gnu packages shellutils)
  31. #:use-module ((guix licenses) #:prefix license:)
  32. #:use-module (guix utils)
  33. #:use-module (guix packages)
  34. #:use-module (guix download)
  35. #:use-module (guix git-download)
  36. #:use-module (guix build-system gnu)
  37. #:use-module (guix build-system go)
  38. #:use-module (guix build-system python)
  39. #:use-module (gnu packages autotools)
  40. #:use-module (gnu packages base)
  41. #:use-module (gnu packages bison)
  42. #:use-module (gnu packages flex)
  43. #:use-module (gnu packages golang)
  44. #:use-module (gnu packages ncurses)
  45. #:use-module (gnu packages pkg-config)
  46. #:use-module (gnu packages python)
  47. #:use-module (gnu packages readline)
  48. #:use-module (gnu packages ruby)
  49. #:use-module (gnu packages shells)
  50. #:use-module (gnu packages tmux))
  51. (define-public boxes
  52. (package
  53. (name "boxes")
  54. (version "1.3")
  55. (source (origin
  56. (method git-fetch)
  57. (uri (git-reference
  58. (url "https://github.com/ascii-boxes/boxes")
  59. (commit (string-append "v" version))))
  60. (file-name (git-file-name name version))
  61. (sha256
  62. (base32
  63. "0b12rsynrmkldlwcb62drk33kk0aqwbj10mq5y5x3hjf626gjwsi"))))
  64. (build-system gnu-build-system)
  65. (arguments
  66. `(#:test-target "test"
  67. #:make-flags (list (string-append "GLOBALCONF="
  68. (assoc-ref %outputs "out")
  69. "/etc/boxes-config"))
  70. #:phases
  71. (modify-phases %standard-phases
  72. (delete 'configure)
  73. (replace 'install
  74. (lambda* (#:key outputs #:allow-other-keys)
  75. (let ((dest (assoc-ref outputs "out")))
  76. (for-each (lambda (x)
  77. (install-file (car x)
  78. (string-append dest "/" (cdr x))))
  79. '(("src/boxes" . "bin")
  80. ("doc/boxes.1" . "share/man/man1")
  81. ("boxes-config" . "etc/")))
  82. #t))))))
  83. (native-inputs `(("flex" ,flex) ("bison" ,bison)))
  84. (synopsis "Command line ASCII boxes")
  85. (description
  86. "This command-line filter program draws ASCII-art boxes around your input
  87. text.")
  88. (home-page "https://boxes.thomasjensen.com/build.html")
  89. (license license:gpl2)))
  90. (define-public zsh-autosuggestions
  91. (package
  92. (name "zsh-autosuggestions")
  93. (version "0.7.0")
  94. (source (origin
  95. (method git-fetch)
  96. (uri (git-reference
  97. (url "https://github.com/zsh-users/zsh-autosuggestions")
  98. (commit (string-append "v" version))))
  99. (file-name (git-file-name name version))
  100. (sha256
  101. (base32
  102. "1g3pij5qn2j7v7jjac2a63lxd97mcsgw6xq6k5p7835q9fjiid98"))))
  103. (build-system gnu-build-system)
  104. (native-inputs
  105. `(("ruby" ,ruby)
  106. ("ruby-byebug" ,ruby-byebug)
  107. ("ruby-pry" ,ruby-pry)
  108. ("ruby-rspec" ,ruby-rspec)
  109. ("ruby-rspec-wait" ,ruby-rspec-wait)
  110. ("tmux" ,tmux)
  111. ("zsh" ,zsh)))
  112. (arguments
  113. '(#:phases
  114. (modify-phases %standard-phases
  115. (add-after 'unpack 'patch-tests
  116. (lambda _
  117. ;; Failing tests since tmux-3.2a
  118. (delete-file "spec/options/buffer_max_size_spec.rb")))
  119. (delete 'configure)
  120. (replace 'check ; Tests use ruby's bundler; instead execute rspec directly.
  121. (lambda _
  122. (setenv "TMUX_TMPDIR" (getenv "TMPDIR"))
  123. (setenv "SHELL" (which "zsh"))
  124. (invoke "rspec")))
  125. (replace 'install
  126. (lambda* (#:key outputs #:allow-other-keys)
  127. (let* ((out (assoc-ref outputs "out"))
  128. (zsh-plugins
  129. (string-append out "/share/zsh/plugins/zsh-autosuggestions")))
  130. (invoke "make" "all")
  131. (install-file "zsh-autosuggestions.zsh" zsh-plugins)
  132. #t))))))
  133. (home-page "https://github.com/zsh-users/zsh-autosuggestions")
  134. (synopsis "Fish-like autosuggestions for zsh")
  135. (description
  136. "Fish-like fast/unobtrusive autosuggestions for zsh. It suggests commands
  137. as you type.")
  138. (license license:expat)))
  139. (define-public zsh-syntax-highlighting
  140. (package
  141. (name "zsh-syntax-highlighting")
  142. (version "0.7.1")
  143. (source (origin
  144. (method git-fetch)
  145. (uri (git-reference
  146. (url "https://github.com/zsh-users/zsh-syntax-highlighting")
  147. (commit version)))
  148. (file-name (git-file-name name version))
  149. (sha256
  150. (base32
  151. "039g3n59drk818ylcyvkciv8k9mf739cv6v4vis1h9fv9whbcmwl"))))
  152. (build-system gnu-build-system)
  153. (native-inputs
  154. `(("zsh" ,zsh)))
  155. (arguments
  156. ;; FIXME: Tests fail when running test regexp
  157. ;; there is no pcre module in the Guix zsh package
  158. `(#:tests? #f
  159. #:phases
  160. (modify-phases %standard-phases
  161. (delete 'configure)
  162. (add-after 'unpack 'patch-paths
  163. (lambda* (#:key outputs #:allow-other-keys)
  164. (let ((out (assoc-ref outputs "out")))
  165. (substitute* "Makefile"
  166. (("/usr/local") out)
  167. (("share/\\$\\(NAME\\)") "share/zsh/plugins/$(NAME)")))))
  168. (add-after 'patch-paths 'make-writable
  169. (lambda _
  170. (for-each make-file-writable
  171. '("docs/highlighters.md"
  172. "README.md"))))
  173. (add-before 'build 'add-all-md
  174. (lambda _
  175. (invoke "make" "all")))
  176. (replace 'check
  177. (lambda* (#:key tests? #:allow-other-keys)
  178. (when tests?
  179. (invoke "make" "test")
  180. (invoke "make" "perf")))))))
  181. (home-page "https://github.com/zsh-users/zsh-syntax-highlighting")
  182. (synopsis "Fish shell-like syntax highlighting for Zsh")
  183. (description
  184. "This package provides syntax highlighting for Zsh. It enables
  185. highlighting of commands whilst they are typed at a Zsh prompt into an
  186. interactive terminal. This helps in reviewing commands before running them,
  187. particularly in catching syntax errors.")
  188. (license license:bsd-3)))
  189. (define-public sh-z
  190. (package
  191. (name "sh-z")
  192. (version "1.11")
  193. (source (origin
  194. (method git-fetch)
  195. (uri (git-reference
  196. (url "https://github.com/rupa/z")
  197. (commit (string-append "v" version))))
  198. (file-name (git-file-name name version))
  199. (sha256
  200. (base32
  201. "13zbgkj6y0qhvn5jpkrqbd4jjxjr789k228iwma5hjfh1nx7ghyb"))))
  202. (build-system gnu-build-system)
  203. (arguments
  204. `(#:tests? #f ; No tests provided
  205. #:phases
  206. (modify-phases %standard-phases
  207. (delete 'configure)
  208. (delete 'build)
  209. (replace 'install
  210. (lambda* (#:key outputs #:allow-other-keys)
  211. (let* ((out (assoc-ref outputs "out"))
  212. (man (string-append out "/share/man/man1"))
  213. (bin (string-append out "/bin")))
  214. (install-file "z.sh" bin)
  215. (chmod (string-append bin "/z.sh") #o755)
  216. (install-file "z.1" man)
  217. #t))))))
  218. (synopsis "Jump about directories")
  219. (description
  220. "Tracks your most used directories, based on ``frecency''. After a short
  221. learning phase, z will take you to the most ``frecent'' directory that matches
  222. all of the regexes given on the command line in order.")
  223. (home-page "https://github.com/rupa/z")
  224. (license license:expat)))
  225. (define-public envstore
  226. (package
  227. (name "envstore")
  228. (version "2.1")
  229. (source
  230. (origin
  231. (method url-fetch)
  232. (uri (string-append "https://finalrewind.org/projects/"
  233. name "/" name "-" version ".tar.bz2"))
  234. (sha256
  235. (base32 "1x97lxad80m5blhdfanl5v2qzjwcgbij2i23701bn8mpyxsrqszi"))))
  236. (build-system gnu-build-system)
  237. (arguments
  238. `(#:test-target "test"
  239. #:make-flags (list "CC=gcc"
  240. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  241. #:phases
  242. (modify-phases %standard-phases
  243. (delete 'configure))))
  244. (home-page "https://finalrewind.org/projects/envstore/")
  245. (synopsis "Save and restore environment variables")
  246. (description "Envstore is a program for sharing environment variables
  247. between various shells or commands.")
  248. (license license:wtfpl2)))
  249. (define-public trash-cli
  250. (package
  251. (name "trash-cli")
  252. (version "0.17.1.14")
  253. (source
  254. (origin
  255. (method url-fetch)
  256. (uri (pypi-uri "trash-cli" version))
  257. (sha256
  258. (base32
  259. "01q0cl04ljf214z6s3g256gsxx3pqsgaf6ac1zh0vrq5bnhnr85h"))))
  260. (build-system python-build-system)
  261. (arguments
  262. `(#:python ,python-2
  263. #:tests? #f ; no tests
  264. #:phases
  265. (modify-phases %standard-phases
  266. (add-before 'build 'patch-path-constants
  267. (lambda* (#:key inputs #:allow-other-keys)
  268. (let ((libc (assoc-ref inputs "libc"))
  269. (coreutils (assoc-ref inputs "coreutils")))
  270. (substitute* "trashcli/list_mount_points.py"
  271. (("\"/lib/libc.so.6\".*")
  272. (string-append "\"" libc "/lib/libc.so.6\"\n"))
  273. (("\"df\"")
  274. (string-append "\"" coreutils "/bin/df\"")))))))))
  275. (inputs `(("coreutils" ,coreutils)))
  276. (home-page "https://github.com/andreafrancia/trash-cli")
  277. (synopsis "Trash can management tool")
  278. (description
  279. "trash-cli is a command line utility for interacting with the
  280. FreeDesktop.org trash can used by GNOME, KDE, XFCE, and other common desktop
  281. environments. It can move files to the trash, and remove or list files that
  282. are already there.")
  283. (license license:gpl2+)))
  284. (define-public direnv
  285. (package
  286. (name "direnv")
  287. (version "2.28.0")
  288. (source
  289. (origin (method git-fetch)
  290. (uri (git-reference
  291. (url "https://github.com/direnv/direnv")
  292. (commit (string-append "v" version))))
  293. (file-name (git-file-name name version))
  294. (sha256
  295. (base32
  296. "0yk53jn7wafklixclka17wyjjs2g5giigjr2bd0xzy10nrzwp7c9"))))
  297. (build-system go-build-system)
  298. (arguments
  299. '(#:import-path "github.com/direnv/direnv"
  300. #:phases
  301. (modify-phases %standard-phases
  302. (add-after 'install 'install-manpages
  303. (lambda* (#:key outputs #:allow-other-keys)
  304. (let* ((out (assoc-ref outputs "out"))
  305. (man (string-append out "/share/man/man1")))
  306. (mkdir-p man)
  307. (with-directory-excursion "src/github.com/direnv/direnv"
  308. (install-file "man/direnv.1" man)
  309. (install-file "man/direnv-stdlib.1" man)
  310. (install-file "man/direnv.toml.1" man)))))
  311. (replace 'check
  312. (lambda* (#:key tests? #:allow-other-keys)
  313. (when tests?
  314. (setenv "HOME" "/tmp")
  315. (with-directory-excursion "src/github.com/direnv/direnv"
  316. ;; The following file needs to be writable so it can be
  317. ;; modified by the testsuite.
  318. (make-file-writable "test/scenarios/base/.envrc")
  319. ;; We need to manually run test because make test
  320. ;; tries to use go modules
  321. (invoke "go" "test" "./...")
  322. ;; Clean up from the tests, especially so that the extra
  323. ;; direnv executable that's generated is removed.
  324. (invoke "make" "clean")))
  325. #t)))))
  326. (native-inputs
  327. `(("go-github-com-burntsushi-toml" ,go-github-com-burntsushi-toml)
  328. ("go-github-com-direnv-go-dotenv" ,go-github-com-direnv-go-dotenv)
  329. ("go-github-com-mattn-go-isatty" ,go-github-com-mattn-go-isatty)
  330. ("go-golang-org-x-mod" ,go-golang-org-x-mod)
  331. ("which" ,which)))
  332. (home-page "https://direnv.net/")
  333. (synopsis "Environment switcher for the shell")
  334. (description
  335. "direnv can hook into the bash, zsh, tcsh, and fish shells to load
  336. or unload environment variables depending on the current directory. This
  337. allows project-specific environment variables without using @file{~/.profile}.
  338. Before each prompt, direnv checks for the existence of a @file{.envrc} file in
  339. the current and parent directories. This file is then used to alter the
  340. environment variables of the current shell.")
  341. (license license:expat)))
  342. (define-public fzy
  343. (package
  344. (name "fzy")
  345. (version "1.0")
  346. (source
  347. (origin
  348. (method git-fetch)
  349. (uri (git-reference
  350. (url "https://github.com/jhawthorn/fzy")
  351. (commit version)))
  352. (file-name (git-file-name name version))
  353. (sha256
  354. (base32
  355. "1gkzdvj73f71388jvym47075l9zw61v6l8wdv2lnc0mns6dxig0k"))))
  356. (build-system gnu-build-system)
  357. (arguments
  358. '(#:make-flags (list "CC=gcc"
  359. (string-append "PREFIX=" (assoc-ref %outputs "out")))
  360. #:phases
  361. (modify-phases %standard-phases
  362. (delete 'configure))))
  363. (home-page "https://github.com/jhawthorn/fzy")
  364. (synopsis "Fast fuzzy text selector for the terminal with an advanced
  365. scoring algorithm")
  366. (description
  367. "Most other fuzzy matchers sort based on the length of a match. fzy tries
  368. to find the result the user intended. It does this by favouring matches on
  369. consecutive letters and starts of words. This allows matching using acronyms
  370. or different parts of the path.
  371. fzy is designed to be used both as an editor plugin and on the command
  372. line. Rather than clearing the screen, fzy displays its interface directly
  373. below the current cursor position, scrolling the screen if necessary.")
  374. (license license:expat)))
  375. (define-public hstr
  376. (package
  377. (name "hstr")
  378. (version "2.3")
  379. (source (origin
  380. (method git-fetch)
  381. (uri (git-reference
  382. (url "https://github.com/dvorka/hstr")
  383. (commit version)))
  384. (file-name (git-file-name name version))
  385. (sha256
  386. (base32
  387. "1chmfdi1dwg3sarzd01nqa82g65q7wdr6hrnj96l75vikwsg986y"))))
  388. (build-system gnu-build-system)
  389. (arguments
  390. `(#:phases
  391. (modify-phases %standard-phases
  392. (add-before 'build 'adjust-ncurses-includes
  393. (lambda* (#:key make-flags outputs #:allow-other-keys)
  394. (let ((out (assoc-ref outputs "out")))
  395. (substitute* "src/include/hstr_curses.h"
  396. (("ncursesw\\/curses.h") "ncurses.h"))
  397. (substitute* "src/include/hstr.h"
  398. (("ncursesw\\/curses.h") "ncurses.h")))
  399. #t)))))
  400. (native-inputs
  401. `(("autoconf" ,autoconf)
  402. ("automake" ,automake)
  403. ("pkg-config" ,pkg-config)))
  404. (inputs
  405. `(("ncurses" ,ncurses)
  406. ("readline" ,readline)))
  407. (synopsis "Navigate and search command history with shell history suggest box")
  408. (description "HSTR (HiSToRy) is a command-line utility that brings
  409. improved Bash and Zsh command completion from the history. It aims to make
  410. completion easier and more efficient than with @kbd{Ctrl-R}. It allows you to
  411. easily view, navigate, and search your command history with suggestion boxes.
  412. HSTR can also manage your command history (for instance you can remove
  413. commands that are obsolete or contain a piece of sensitive information) or
  414. bookmark your favourite commands.")
  415. (home-page "http://me.mindforger.com/projects/hh.html")
  416. (license license:asl2.0)))
  417. (define-public shell-functools
  418. (package
  419. (name "shell-functools")
  420. (version "0.3.0")
  421. (source (origin
  422. (method git-fetch)
  423. (uri (git-reference
  424. (url "https://github.com/sharkdp/shell-functools")
  425. (commit (string-append "v" version))))
  426. (file-name (git-file-name name version))
  427. (sha256
  428. (base32
  429. "0d6zzg7cxfrzwzh1wmpj7q85kz33sak6ac59ncsm6dlbin12h0hi"))))
  430. (build-system python-build-system)
  431. (home-page "https://github.com/sharkdp/shell-functools/")
  432. (synopsis "Functional programming tools for the shell")
  433. (description "This package provides higher order functions like map,
  434. filter, foldl, sort_by and take_while as simple command-line tools. Following
  435. the UNIX philosophy, these commands are designed to be composed via pipes. A
  436. large collection of functions such as basename, replace, contains or is_dir
  437. are provided as arguments to these commands.")
  438. (license license:expat)))