Projects - CLI Productivity Config |
||
BackgroundMostly inspired by DOS and the 1200+ batch files I was gifted in early 2017, CLI Productivity Config is a project to port the concepts over to the Linux shell (whether it be for Bash or fish). This project has been developed and tested on Debian 9 (Stretch), but should also work great on Ubuntu 17 (Zesty Zapus, Artful Aardvark). If using the Ubuntu Xenial LTS or any derivative (e.g. Linux Mint 18.x), you may find that the columnar expression for the 'dirw' command is not aligned. This is due to a package (BSDMainUtils) being ever-so-slightly too old (9.0.6) for the required feature to appropriately handle escaped characters (9.0.7). Since Ubuntu and the derivatives are currently catching up to a newer version (first LTS being Bionic Beaver), instead of making anyone face an upgrade path, I built from source an updated (9.0.7) package, for both i386 and amd64 architectures for Ubuntu 18.04 and derivatives. The project is somewhere between slow crawl and hiatus right now - I have a concept for something that is going to shake up enough but it won't make sense unless pushed all at once. InstallationGetting these tools is relatively easy. The method used below assumes the 'git' package is installed. If not (and don't care to install it either) you can download the package directly.
For the last command, you can either choose which shell you use (or both) as part of the guided script. Will also prompt for installation of standalone scripts (below), if desired. FunctionsCurrently, every function available for Bash is available for fish, and vice versa. Arguably the only exception to this is fish has a function called 'sudo!!' where Bash already has the equivalent 'sudo !!'. ScriptsThe theory is that all of these will be built from Bash. They deploy differently (which have it's perks and drawbacks) than functions. Also, the scripts will likely fit a more specific purpose than functions. SupportI am finding myself very delayed in adding features or finding/fixing issues. Either can be nudged along to my attention by either an issue (being thorough pays off here) or better yet, a pull request if you have code to back up a particular solution. cdbPerforms a search (based on name) below the current working directory to change to any specified matched directory. As this uses a live search, you may not want to use this when then there is a very deep directory structure below, or you will find yourself waiting on the search results. joel@cybaryme ~/B/g/android_kernel_asus_msm8916> cdb arm a 1) ./virt/kvm/arm b 2) ./arch/arm c 3) ./Documentation/devicetree/bindings/arm d 4) ./Documentation/arm e 5) ./Documentation/zh_CN/arm f 6) ./sound/arm g 7) ./tools/perf/arch/arm h 8) ./drivers/scsi/arm Select directory by letter or number: 2 joel@cybaryme ~/B/g/a/a/arm> cdflMove anywhere in the filesystem without having to type out or tab through a full path - enter the first letter of every path level instead. '~' and '/' can be used as a prefix (to start with home or root, respectively), or use '.' anywhere in the parameter to go up one level. joel@cybaryme /u/l/bin> cdfl ~B. joel@cybaryme ~> cdfl . joel@cybaryme /home> cd joel@cybaryme ~> cdfl Bg a 1) ./Build/github b 2) ./Build/genymotion c 3) ./Build/git: Select directory by letter or number: 1 joel@cybaryme ~/B/github> cdfl .. joel@cybaryme ~> cdfl /ulb a 1) /usr/lib/blt2.5 b 2) /usr/lib/binfmt-support c 3) /usr/lib/binfmt.d d 4) /usr/local/bin Select directory by letter or number: 4 joel@cybaryme /u/l/bin> cdhDisplays a history of visited directories to allow changing back to one of them. joel@cybaryme ~/B/g/a/a/arm> cdh c 3) ~/Build b 2) ~ a 1) ~/Build/github/android_kernel_asus_msm8916 Select directory by letter or number: 3 joel@cybaryme ~/Build> cdh d 4) ~/Build c 3) ~ b 2) ~/Build/github/android_kernel_asus_msm8916 a 1) ~/Build/github/android_kernel_asus_msm8916/arch/arm Select directory by letter or number: 3 joel@cybaryme ~> clihelpA helper message about common keyboard shortcuts. Can also be invoked by pressing ^h (CTRL + H) joel@cybaryme ~> clihelp Keyboard Shortcuts: CTRL + C – Cancels current command CTRL + S – Repeats the last command with sudo CTRL + L – Provide directory listing in current working directory CTRL + U – Cuts text up until the cursor CTRL + K – Cuts text from the cursor until the end of the line CTRL + W – Cut word behind cursor CTRL + Y – Pastes text CTRL + E – Move cursor to end of line CTRL + A – Move cursor to the beginning of the line ALT + Backspace – Delete previous word CTRL + Left – Move cursor one word to the left CTRL + Right – Move cursor one word to the right Home – Move cursor to beginning of line End – Move cursor to end of the line Tab – Autocomplete current command/argument joel@cybaryme ~> dirwA compact listing of the current directory with colour. Long names are truncated in the listing. Can also be invoked by pressing ^l (CTRL + L) joel@cybaryme ~/B/g/android_kernel_asus_msm8916> dirw android/ AndroidKernel.mk arch/ block/ COPYING CREDITS crypto/ Documentation.../ drivers/ firmware/ fs/ include/ init/ ipc/ Kbuild Kconfig kernel/ lib/ MAINTAINERS Makefile* mm/ net/ README REPORTING-BUGS samples/ scripts/ security/ sound/ tools/ usr/ virt/ joel@cybaryme ~/B/g/android_kernel_asus_msm8916> dirlast / dirprev / actlast / actprevThese functions either display or act (copy, move or remove) upon files that match a certain age (modified date), whether they are newer than a specific week/day/hour/minute (dirlast/actlast) or older (dirprev/actprev). The searches can also include a (wildcarded) name search as well. joel@cybaryme ~/B/g/cli-productivity-config> dirlast D 5 '*.fish' -rl -rw-r--r-- 1 joel joel 2850 Sep 1 17:53 ./fish/functions/dir-core.fish -rw-r--r-- 1 joel joel 50 Sep 1 17:05 ./fish/functions/actlast.fish -rw-r--r-- 1 joel joel 3826 Sep 1 17:53 ./fish/functions/act-core.fish -rw-r--r-- 1 joel joel 50 Sep 1 17:13 ./fish/functions/dirprev.fish -rw-r--r-- 1 joel joel 50 Sep 1 17:15 ./fish/functions/dirlast.fish -rw-r--r-- 1 joel joel 50 Sep 1 17:12 ./fish/functions/actprev.fish -rw-r--r-- 1 joel joel 2634 Sep 4 09:25 ./fish/functions/cdh.fish joel@cybaryme ~/B/g/cli-productivity-config> actprev W 2 cp .. Action: cp The following files will be affected: ./README.md ./INSTALL-fish.sh* ./LICENSE ./INSTALL-Bash.sh* Do you wish to continue? [yes|no]: y joel@cybaryme ~/B/g/cli-productivity-config> editaddOpens a file in your default editor, and then marks it for inclusion in the next git commit ('git status' is also run to verify the addition). joel@cybaryme ~/B/g/cli-productivity-config> editadd Bash/.bash_functions M Bash/.bash_functions joel@cybaryme ~/B/g/cli-productivity-config> mkedMakes and enters a specified directory (or several nested ones when applicable). joel@cybaryme ~/B/g/cli-productivity-config> mked examples/Bash joel@cybaryme ~/B/g/c/e/Bash> sudo!!Repeats the last command, with sudo preceeded. In bash, this already exists as 'sudo !!'. Can also be invoked in either shell by pressing ^s (CTRL + S) joel@cybaryme ~> apt-get update Reading package lists... Done W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted) E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) E: Unable to lock directory /var/lib/apt/lists/ W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied) W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied) joel@cybaryme ~> sudo!! [sudo] password for joel: Ign:1 http://mirror.its.dal.ca/debian jessie InRelease Ign:2 http://mirror.its.dal.ca/debian stretch InRelease Hit:3 http://mirror.its.dal.ca/debian stretch-updates InRelease Hit:4 http://mirror.its.dal.ca/debian jessie-backports InRelease Hit:5 http://mirror.its.dal.ca/debian jessie Release Hit:6 http://mirror.its.dal.ca/debian stretch Release ... timerA cut down 'time' command showing only the "wall clock" time a command has run for. joel@cybaryme ~> timer sleep 1 Ran for 0:01.00 min:sec joel@cybaryme ~> wakesshInvokes Wake-On-LAN (WOL) for a PC defined by a profile, then remotes into the system once online. joel@cybaryme ~> wakessh android 192.168.1.111 not turned on. WOL packet sent at 19:23 Waiting a Minute... Trying again..... 192.168.1.111 is UP as on 19:24 Attempting to SSH android@192.168.1.111... Linux terminatrix 4.14.0-0.bpo.3-amd64 #1 SMP Debian 4.14.13-1~bpo9+1 (2018-01-14) x86_64 Last login: Sat Mar 10 11:33:38 2018 from 192.168.1.101 android@terminatrix:~$ |