Giter Site home page Giter Site logo

iridakos / goto Goto Github PK

View Code? Open in Web Editor NEW
864.0 22.0 62.0 3.2 MB

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

Shell 100.00%
bash aliases directories utility productivity registered-aliases linux zsh

goto's People

Contributors

calinou avatar csonuryilmaz avatar dmd avatar escozul avatar f1rstlady avatar gahag avatar iridakos avatar jblond avatar jcavejr avatar jshort avatar kaitokidi avatar luotaipeng avatar omrihab avatar robertpro avatar shawalli avatar suboptimal avatar vanhtuan0409 avatar vigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goto's Issues

zsh: command not found: compdef

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

OSX doesn't install to path

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

Error when using '-l' when there are no aliases yet

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 :)

ZSH _complete_goto_aliases autocomplete error

OSX 10.11

bash --version

GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin15.6.0)

zsh --version

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!

Ungregistered alias on MacOS

$ 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

How to create an alias for goto itself?

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.

shellcheck changes broke bash 3.2 and 4.4 completion and zsh '-c' flag.

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

dae1cbd

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.

Goto breaked after update to 1.2.4

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

bash-completions breaking macOS

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?

host-specific aliases

I'd like to be able to specify an alias as only being available on a certain host (i.e., the current one).

`goto` completions don't appear

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.

Windows support?

Tried in Git Bash in Windows but nothing happens.
Is Windows supported in any way?

goto does not work for me on MacOS 10.15

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

completion doesn't format in columns

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?

Question: brew package of goto is out of date

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

Storage of config file should use XDG_CONFIG_HOME if configured

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.

goto --expand not return 1 on error

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

On zsh, goto is unable to create aliases if ~/.goto does not exist

  • zsh version: zsh 5.5.1 (x86_64-redhat-linux-gnu) with Prezto
  • goto version: cd760f2

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).

source command fails

when I run:

source path/to/goto.bash

I get this error:
goto.bash:273: command not found: complete

I use a Mac.

Goto not working when in WSL and also using zsh

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 .

Partly not working on OSX 10.13.6

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.

Make goto ksh compatible

The changes needed are:

  1. change 'local' to 'typeset'

  2. Do not attempt to evaluate (even conditioned out) the _complete functions, which contain some bash/zsh specific syntax.

  3. Disable any features (like -p/-o) that don't exist under ksh.

Fish shell support

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?

ohmyszsh error /usr/share/goto/goto.sh:456: command not found: compdef

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 :)

Issue in <TAB> autocomplete

_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

Install not working Ubuntu

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.

https://imgur.com/a/hN5nMcN

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.