Shunpo: Minimalist bash tool to make directory navigation a little bit faster
github.com
github.com
https://github.com/zsh-users/zsh-autosuggestions?tab=readme-...
Auto completion, abbreviations, better syntax, and especially the auto complete is like magic. It also seems to "know" in which working directories some commands work and won't suggest them if they arent.
Extremely useful on a daily basis.
$ cat .inputrc
set editing-mode vi
set keymap vi-command
k: history-search-backward
j: history-search-forward
Type any prefix, press `<esc>k` (or `<up>` in emacs mode) and it'll prefix match on history. Keep pressing `k` for older matches.Fish really is amazing and it really is worth the minor transition costs.
The 'It' above is actually the user as auto-complete is context dependent, so fish prioritises search results based on commands that were previously used within the current directory.
So I too went back to zsh.
# Allow .. through ........... (yup!) to cd up some number of directories.
for i in {1..10}; do
spaces=$(printf "%${i}s")
alias "${spaces// /.}."="cd ${spaces// /../}"
done
Going into it, I thought it would be something I'd use all the time. In practice all I ever use is `..` and not nearly as much as I originally imagined I would.The only thing I'm missing from zsh is path aware auto completion... supposedly this works if you enable the sqlite history for nushell but iirc it was buggy.
https://gist.github.com/chanux/1119556 (bash) https://gist.github.com/chanux/9411092 (fish)
That's `za <n>` to go back n directories up. It's a decade old and I still use this everyday.
I experimented with jumping up directory path by name with `xs`. But I don't use it that often (at all).
https://gist.github.com/chanux/08c6f53472190a02b33bd49100163...
alias .='dot_func'
alias ..='cd ../..'
alias ...='cd ../../..'
alias ....='cd ../../../..'
alias .....='cd ../../../../..'
dot_func ()
{
if [ $# -eq 0 ]; then
cd ..
else
source "$@"
fi
}
It’s usually enough. :)`cd ..` coupled with `cd ~` seems to be good enough, really.
Super handy. This looks like it might be more polished version.
https://github.com/wting/autojump
just looked at it again it also has a jc command for child directories and commands to open file explorer that I never used.
Well ok, Jef Raskin decided that and I happen to agree with him.
My extension is "anything that requires traversing either taxonomies or invisible geometries is too much to ask." So for instance, tmux splits previous-pane and previous-window into two things so the "last thing I was looking at" now asks you to consider whether that was in a pane or a window[1] ... as if you had taken the time to diligently organize it (traversing taxonomy). Xorg's split of the clipboard into CLIPBOARD, PRIMARY, SECONDARY, CUT_BUFFER0-9 and every program having a different opinion on how to copy and paste into them is another one. And then tools like tmux have their own and tools like vim and emacs have their own. So vim, inside of tmux, inside of ssh, inside of some terminal ... right. [2]
Similarly, the multi-dimensionality of many tiled window managers (where you have up, down, left, right, tab left, tab right, workspace (up/down/left/right) etc ...) is like navigating via hypercube.
It's way too complicated to keep a mental model of and leads to lots of errors. I still use one because there's no other reasonable way to leverage the multi-tasking abilities of modern machines but it leads a lot to be desired. My user error rate is probably over 80%.
I'm sure some geniuses can do it but most people cannot.
[1] I have a fix!
Add this to .tmux.conf
set -g focus-events on
bind-key l run-shell "$HOME/bin/tmux-last switch"
set-hook -g pane-focus-out "run-shell 'tmux set-option @out #{pane_id}"
set-hook -g pane-focus-in "run-shell '$HOME/bin/tmux-last in #{pane_id} #{@out}"
Where tmux-last is https://9ol.es/tmp/tmux-last[2] If you are a traditionalist using xterm or some derivative, this block taken from my .Xresources should be enlightening
*VT100*translations: #override \n\
~Shift~Ctrl<Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0) \n\
Shift~Ctrl<Btn2Up>: insert-selection(CLIPBOARD, CUT_BUFFER1) \n\
Ctrl Shift <Key>V: insert-selection(CLIPBOARD, CUT_BUFFER1) \n\
Ctrl <Key>V: insert-selection(PRIMARY, CUT_BUFFER0) \n\
~Shift <BtnUp> : select-end(PRIMARY, CUT_BUFFER0) \n\
Shift <BtnUp> : select-end(CLIPBOARD, CUT_BUFFER1) \n\
It's still strait jacket drooling insanity, but at least it's a little less.Probably the actual fix in X would be to somehow route all clipboards through DBus so then the user AND the application can have their own opinions and not have to have a bunch of accommodations for each other.
syntax:
projects <project-name> <match index>
alias: function projects() {
if [ -z "$1" ]; then
echo "please provide a project name"
return
fi
local allMatches=$(find ~/Documents/projects -maxdepth 2 -type d -name "*$1*" -print)
local firstMatch=$(echo "$allMatches" | head -n ${2:-1} | tail -n 1)
if [ -z "$firstMatch" ]; then
echo "no matches found"
return
else
if [ $(echo "$allMatches" | wc -l) -gt 1 ]; then
echo "matches found:"
echo "$allMatches" | awk '{print NR ") " $0}'
fi
cd "$firstMatch"
fi
}Personally, I've been using z (<https://github.com/rupa/z>) for ages and never really needed more.
[0] https://www.gnu.org/software/bash/manual/html_node/Variable-...
devhome () {
cd $DEV_HOME/${~1}(/)
}
This assumes an environment variable DEV_HOME is assigned to be the location of the top-level directory for a given project. An example of its use is: devhome mod*/foo/src/**/some-dir
0 - https://www.zsh.org/ alias rr='cd $(git rev-parse --show-toplevel)'If this is the preferred approach, however, an alternative zsh definition for devhome could be:
devhome () {
cd $(git rev-parse --show-toplevel) && cd ./${~1}(/)
} cdranger() {
local tmpfile="$(mktemp)"
local cdto
ranger --show-only-dirs --choosedir="$tmpfile" "$@"
cdto="$(cat $tmpfile)"
rm -f "$tmpfile"
if [ "$cdto" ]; then
cd "$cdto"
fi
}I wrote a very similar tool for myself a long time ago: “wd” or Working Directory. Uses similar numeric slots but also has named “schemes” and sets environment variables for your slots for you.
fzf
zoxide
fd
Small helpers are always good to have. Thanks for sharingBetween all of those it's hard to think of a better experience navigating a filesystem.
yazi
along with kitty. Unfortunately I did not find an (acceptable) way to simulate the behaviour of ddterm
GNOME extension with kitty or alacritty. A dropdown Terminal with image protocol for file preview would be very cool.I personally tend to wezterm nowadays, kitty breaks too many things, especially over tmux/ssh (or combination thereof and with zellij)
I'll also admit to liking iterm2 on macos a lot
I'm not really sure why I like it so much, but it feels natural.
https://gist.github.com/GNOMES/6bf65926648e260d8023aebb9ede9...
Would also be nice to be able create bookmarks to regularly used commands as part of the "Shunpo package". That way one wouldn't need to use another tool for these type of cases. Thoughts?