iridakos / goto Goto Github PK
View Code? Open in Web Editor NEWAlias and navigate to directories with tab completion in Linux
Home Page: https://iridakos.com/programming/2019/04/10/shell-navigation-with-autocomplete
License: MIT License
Alias and navigate to directories with tab completion in Linux
Home Page: https://iridakos.com/programming/2019/04/10/shell-navigation-with-autocomplete
License: MIT License
tab completion of an alias doesn't format in columns.
To fix I guess you'd have to pass the COMPREPLY
array through column -t
and then back into array form?
Is anyone testing under zsh? I get the below (though I may just not understand something; I'm not a regular zsh user):
[ddrucker@ic-linux7]~% zsh --version
zsh 5.0.2 (x86_64-redhat-linux-gnu)
[ddrucker@ic-linux7]~% . ./goto.sh
./goto.sh:446: command not found: compdef
Just a small bug: The program does not check to make sure the ~/.config directory exists. Until this directory is created, the program will happily report that the shortcut has been created, although it has not.
Tried in Git Bash in Windows but nothing happens.
Is Windows supported in any way?
I installed goto recently on WSL. It didn't work from the first try. So I installed it myself in a different directory where I put most of my global scripts.
But when I investigated the goto script, I realized that it checks if you have a .bashrc file but also checks if you have .zshrc.
However, if it finds .bashrc, it adds the the sourcing script to it and ignore .zshrc.
I have tested the script you guys used to decide which file to use and here is the output:
@DESKTOP-C64TQ1G ➜ testingStuff if [ -f ~/.bashrc ]; then
then> echo ".bashrc exists"
then> fi
.bashrc exists
@DESKTOP-C64TQ1G ➜ testingStuff if [ -f ~/.zshrc ]; then
echo ".zshrc exists"
fi
.zshrc exists
@DESKTOP-C64TQ1G ➜ testingStuff if [ -f ~/.bashrc ]; then
echo "bashrc exists"
elif [ -f ~/.zshrc ]; then
echo "zshrc exists"
fi
bashrc exists
I think the correct behavior in this case is to add it to .zshrc since IF zsh is used, it usually ignores .bashrc and uses its own .zshrc .
I read this closed issue #33 but no luck with the
autoload bashcompinit
bashcompinit
I dont use redhat like it is written at the end of the closed issue, i use manjaro and ohmyzsh.
If it helps when i make some zsh completion i use compctl not compdef, here an example:
_cmpl_cheat() {
reply=($(cheat -l | cut -d' ' -f1))
}
compctl -K _cmpl_cheat cheat
it allows me to autocomplete the cheat
command with all cheatsheet.
I will dig on my side :)
Following the listed instructions to install Goto from git on Ubuntu 18.04.2 LTS leads to a broken install. Attempted install with both sudo and as root both lead to touch: cannot touch '/home/USER/.goto': Not a directory
errors. Each time I attempted to run a goto
command, the error would concatenate another /.goto/
to the file path it was looking for. See linked image for example.
When running goto -l
when you haven't created any aliases yet, the following error is printed: sed: can't read /home/tom/.goto: No such file or directory
. While correct, it may be nice to catch this and tell the user that there are no aliases presently configured.
Thanks for making this tool btw, I think it's gonna be saving me quite some time in the long run :)
🐛 🐸
goto
is an awesome tool and I use it heavily. However I would like to alias goto
itself to something shorter, perhaps g
or gt
. However if I do a simple alias g=goto
, bash completions do not work for the aliased version.
It would be nice if there was an option to install goto
with an aliased name, or some instructions in the README on how to set up an alias such that completions still work, e.g. by registering the same completion functions for the alias as for goto
.
I should be able to say:
goto fo
and if that is a unique prefix in .goto, we should go there without me having to press tab as well.
OSX 10.11
GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin15.6.0)
zsh 5.0.8 (x86_64-apple-darwin15.0)
When using bash, works great. When using ZSH, however, it returns the error. I can register and list entries, and can manually type the whole registered alias. When tab completing registered aliases, it returns the following error:
~ goto -l
git /Users/'username'/GIT
~ goto _complete_goto_aliases:local:4: not valid in this context: git /Users/'username'/GIT)
_complete_goto_aliases:local:4: not valid in this context: git /Users/'username'/GIT)
_complete_goto_aliases:local:4: not valid in this context: git /Users/'username'/GIT)
goto
I know that ZSH substitution is different than bash, but haven't been able to pin down exactly what part of the _complete_goto_aliases function is not substituting correctly
Great tool!
Is bash-completions
required to use goto? I couldn't seem to get it working until I added bash-completions
and set that up via Homebrew. But that broke the default BASH completions in iTerm2. Sorry, I didn't test with the default Terminal before removing bash-completions
and goto. I really like using goto but I can't accept how bash-completions
changes the default behavior under iTerm2. Is it possible to use just goto without bash-completions
?
When stderr is redirected to /dev/null the output of direnv is swallowed. This wouldn't be a problem except direnv can use interactive prompts and so you'll be stuck not knowing that it is asking for. This will also be a problem anywhere the directory is changed. It seems like an option could be added to allow output in these places.
When running source goto.sh
in the fish shell, it gives this error:
goto.sh (line 42): Unexpected ')' found, expecting '}'
-c|--cleanup)
^
from sourcing file goto.sh
source: Error while reading file “goto.sh”
I suspect this is because the fish shell is not POSIX-compliant. Could support for the fish shell be added?
Register completions for the following new commands:
-x
, --expand
-p
, --push
-o
, --pop
Hi, brew version is old :)
brew info goto
goto: stable 2.0.0
the current version is : goto version 2.1.0
who is maintaining the brew package? @iridakos you? I'm planning to add a sort feature :) using it locally :) and configurable... looking forward to seeing an update on brew
bronxwhq ................... /Users/vigo/Development/BronxWHQ
download-test1 ............. /Users/vigo/DownloadsTest1
download-test2 ............. /Users/vigo/DownloadsTest2
download-test3 ............. /Users/vigo/DownloadsTest3/_new
downloads .................. /Users/vigo/Downloads
dropbox .................... /Users/vigo/Dropbox
go-company1 ................ /Users/vigo/.local/gopackages/src/github.com/company1
go-mod-cache ............... /Users/vigo/.local/gopackages/pkg/mod
go-projectx ................ /Users/vigo/.local/gopackages/src/github.com/projectx
go-src ..................... /Users/vigo/.local/gopackages/src/github.com
go-vigo .................... /Users/vigo/.local/gopackages/src/github.com/vigo
open-source ................ /Users/vigo/Development/OpenSource
projectx ................... /Users/vigo/Development/projectx
textmate-bundles ........... /Users/vigo/Library/Application Support/TextMate/Bundles
textmate-bundles-powertools /Users/vigo/Library/Application Support/TextMate/Bundles/PowerTools.tmbundle
vbyazilim .................. /Users/vigo/Development/vbyazilim
vbyazilim-website .......... /Users/vigo/Development/vbyazilim/vbyazilim.com
vigo-ugurozy-website ....... /Users/vigo/Development/vigo/ugur.ozyilmazel.com
Allow users to be informed of their installed goto
script version.
I couldn't get the script to accept spaces in the directory name.
This was introduced on commit 6cfe42e.
The GOTO_DB
variable is not being set unless the goto
command executes for the first time. So if completion takes place before executing goto
in a shell, aliases are not displayed.
If ~/.goto
does not exist, goto is unable to create aliases. It will print an error, claim success but will not effectively save anything:
~/Documents/Git/godotengine/godot
❯ goto -r godot .
_goto_register_alias:34: no such file or directory: /home/hugo/.goto
Alias 'godot' registered successfully.
~/Documents/Git/godotengine/godot
❯ goto -l
You haven't configured any directory aliases yet.
~/Documents/Git/godotengine/godot
❯ goto godot
goto error: unregistered alias godot
This can be worked around by entering touch ~/.goto
. Note that this only applies to zsh — it seems to work fine with Bash when ~/.goto
does not exist (i.e. the file will be created automatically).
If $GOTO_DB is already set in the environment, use it instead of ~/.goto.
This would enable #14 and many other possibilities.
Hi,
I'm working on #7 and right before pushing my changes to my fork, I pulled the latest changes from the upstream and found that
Has broken bash 3.2 (default on MacOS), bash 4.4 completion, and the -c flag (because of mapfile) for zsh.
Can we try to keep this code bash/zsh agnostic. The shellcheck gripes do offer options that don't use mapfile (only in bash 4 and above).
As to why completion is broken in bash 4.4, I'm not sure. It seems that it is trying to execute the cmd of the discovered aliases, not present them to the shell.
It would be great if goto was available via Homebrew on macOS
... to better distinguish the aliases from the directories.
Report changes upon version bumps.
brew install goto
Close all terminal windows, and reopen
goto
-bash: goto: command not found
I've tried brew unlink goto; brew link goto
, and uninstalled and reinstalled,
ll /usr/local/Cellar/goto/1.2.3/etc/bash_completion.d/goto.sh
-rw-r--r-- 1 sowen admin 11402 Mar 14 13:47 /usr/local/Cellar/goto/1.2.3/etc/bash_completion.d/goto.sh
I've also tried
chmod +x /usr/local/Cellar/goto/1.2.3/etc/bash_completion.d/goto.sh
Something is still wrong with the brew package for goto on OSX
If goto --expand
would return 1 on error (as it does in other commands), it could be used easier to check if alias exist before creating.
E.g.:
if ! goto -x foo >/dev/null 2>&1; then
goto -r foo /bar
fi
I can install goto without having any problems via brew but it won't start.
brew install goto
/usr/local/Cellar/goto/1.2.3: 6 files, 18.9KB, built in 4 seconds
If I try starting it:
goto
zsh: command not found: goto
With MacOs 10.15, Apple changed the default shell on MacOS to zsh. Maybe that's the problem..
I tried solving this issue by doing this (without success): #36 (comment)
OS: MacOS 10.15.1
Shell: zsh (default shell)
goto Version: 1.2.3 (newest version I get via brew install goto
)
never had such a problem with any brew package
If the XDG_CONFIG_HOME variable is configured, that should be used as the default storage location (commonly ~/.config).
This has become the newer standard location for "dotfiles" and config files for Linux applications to try keeping the home path cleaner.
Still allowing an override is good, but the default should be changed to be more compliant with the Linux standard.
This is partly not working on OSX High Sierra 10.13.6.
I can add an alias, remove an alias but I cannot list aliases nor can I "goto "
I've uninstalled, reinstalled, rebooted between and after installs, nothing seems to fix it.
$ goto -r dev /Users/mipeter3/Development/
Alias 'dev' registered successfully.
$ goto dev
goto error: unregistered alias dev
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.
This is on Mac OSX 10.13.3
I'd like to be able to specify an alias as only being available on a certain host (i.e., the current one).
Hi, I'm glad that this project is still under maintenance
Unfortunately, It gets broken after updating to 1.2.4
The error is: bad set of key/value pairs for associative array
Environment: ZSH
Thank a lot for an awesome tool
The changes needed are:
change 'local' to 'typeset'
Do not attempt to evaluate (even conditioned out) the _complete functions, which contain some bash/zsh specific syntax.
Disable any features (like -p/-o) that don't exist under ksh.
_arguments:13: bad pattern: -([AMO]|[CRSWnsw])
_arguments:13: bad pattern: -([AMO]|[CRSWnsw])
_arguments:13: bad pattern: -([AMO]*|[CRSWnsw])
goto version 2.0.0
terminal zsh 5.7.1 (x86_64-debian-linux-gnu)
PD: Wordk fine in bash
when I run:
source path/to/goto.bash
I get this error:
goto.bash:273: command not found: complete
I use a Mac.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.