I have a folder 'test' which contains another folder 'test2'
When I type 'cd te[tab]' it auto-completes to 'cd test/'
How do I make it autocomplete to 'cd test/test2/', without hitting tab again?
To clarify: test is the only folder/file in the folder test. I want this to work recursively so if there is a folder/with/a/lot/of/single/files/or/folders/in/it
Bash supports programmable auto completion (at least since version 3.0). There is some documentation in the bash manual on
http://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion
It might also be a good idea to look at existing scripts to get an idea how to really make use of that feature. Debian for example has a /etc/bash_completion file with completion scripts for various programms. I'm sure other distributions have something similar
It is hard for bash to understand either you want to jump to test or to test/test. So I believe there is no standard settings.
But you can always alias commands for particular cases like
alias cdtest="cd test/test"
Related
I come here, just for context, based on this question.
How to set bash aliases for docker containers in Dockerfile?
I know I could create an alias for a certain command and inject them to the bash profile of the users.
For example:
alias kc=/opt/kafka/bin/kc.sh
I could also add the directory to the path (probably this is what I'll do).
But I wanted to know is there a way I could create this as a kind of command?
Is alias the only way to do this, and is there a way I could create the alias for all users not depending on the bash they use?
For example if I would want to create a command something like
my_command is there a way to do this?
Probably this question is showing lots of lack of knowledge of the actual operating system but I just wanted to know what options I would have, and my google searches always show the same results so I thought I asked here
You have the command already: /opt/kafka/bin/kc.sh.
I understand that you want to make it available to your users as a simple kc.sh or kc, without the directory prefix. The solution is to either put that directory into the PATH variable, typically done in /etc/profile; or put the command respectively a (symbolic) link to it into a directory which is already in the PATH, like /bin/, /usr/bin or /usr/local/bin.
Putting the directory into the PATH is probably the better solution, also because there are probably more useful commands to be found. If you don't like kc.sh but want a simple kc you can still make a link in the same directory, e.g. by performing cd /opt/kafka/binand then ln -s kc.sh kc.
Hi I am having a problem with setting alias in mac after I start the screen command, I have alias for working with git, like
commit=git commit
they work as I expect when I start my terminal (iTerm2), but then sometimes I use screen to have simultaneous instances in remotes servers and virtual machines I work with. After this the alias disappear(command not found).
Does anyone know why or how solve it?
To make the alias work, you must use the alias command. For example, to create an alias in Bash you do:
$ alias commit="git commit"
This works temporarily ie.: in your current shell. In order to make it "stick", you must put it in your ~/.bashrc. That will make it be sourced to all instances of Bash you'll invoke during your terminal session.
When you start screen, it starts a separate Bash too, so you'll be covered.
You write something about VMs. If you need this alias to work there, you must make ~/.bashrc on these VMs to have the same aliases. But that's the other story. You should already know how to achieve what you want.
You need to make sure your aliases are defined in ~/.bashrc to ensure they get included in all logins. You can test this out: edit your ~/.bashrc to include this line:
echo "bashrc"
And then edit your ~/.bash_profile to include this line:
echo "bash_profile"
You'll see when you start screen that only "bashrc" is displayed.
See this question for much more detail on the subject.
EDIT:
I was generally interested to know how people had their go autocomplete set up for vim and was looking for advice on it.
Related to my original question, I think I know I can just go to:
https://github.com/nsf/gocode
copy the files that they provide there and just start using the vim autocomplete. However, I wanted to know what people thought and how the go community has the vim autocomplete set up.
Also, I have followed the intructions as were posted there and I still cannot make the autocompletion work for my go in vim. So I am looking for other alternatives or ideas on how to make it work. Not sure what the problem is. Currently when I try to autocomplete it simply writes the word PANIC instead of showing me the options for autocompletion.
ORIGINAL:
I was trying to set up my vim such that it could auto complete the Go programming language, however, I was following the instructions in the following page:
https://github.com/nsf/gocode
and I was not sure what they meant and I was a little scared of maybe changing my vim set up in a way that might be damaging by doing it wrongly.
The first thing that confused me is it says:
Install official Go vim scripts from $GOROOT/misc/vim. If you did that already, proceed to the step 2.
However, I was not sure what that even meant. I did go to that directory in my terminal and read the readme.txt file and I it said how to activate the syntax highlighting which I already had anyway. Is that everything I have to do for that step?
On step 2 it says:
do:
vim/update.sh
They actually provide the code that update.sh is but I was not sure what the beginning of the cp command meant i.e. its:
#!/bin/sh
mkdir -p "$HOME/.vim/autoload"
mkdir -p "$HOME/.vim/ftplugin/go"
cp "${0%/*}/autoload/gocomplete.vim" "$HOME/.vim/autoload"
cp "${0%/*}/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go"
But what does the ${0%/*} part do? and even if I know what the update.sh is, where do I even run this, since this vim/update.sh is done at a relative path?
I know update.sh wants me to copy some files to $HOME/.vim/ftplugin/go and $HOME/.vim/autoload, but I even did a find from ~ and couldn't find such files, so I am unsure on what to copy. I know where it should go, but not where the file even is. Does someone know where those files are or an easier or more detailed explanation on how to make vim auto-complete for go?
Thanks for the help in advance! :)
Some of the problems that I have discovered that I have, not sure if its expected, but in the $GOROOt/misc/vim/ftplugin/go I do not have the gocomplete.vim file at all. I have other stuff that seems irrelevent like an fmt.vim import.vim and a test.sh file.
But the odd thing is that at $GOROOt/misc/autoload I do not have the gocomplete.vim file but I instead have a complete.vim file. Not sure if that the same or why the name of the file would have changed. Anyway has their go autocomplete set up and mind sharing what they have and if they know what the differences might be with what I have encountered? Thanks!
ADDITION to Question
I am also generally interested in how other people have their auto-complete set up for their go in vim. Feel free to share that too!
Have you executed the update.sh command already? I'm pretty confident that it will work.
All of your Vim configuration is stored in ~/.vim/, ~/.vimrc and ~/.gvimrc (with Vim 7.4, you can put the last two also inside the first directory). To backup your Vim configuration, just store those somewhere (or put all of your dotfiles under version control, as many now do).
The ${0%/*} manipulates the script's file name ($0) like dirname does: It cuts off the script file name itself (everything at the end * until the last /). With this, you can invoke the script from anywhere, e.g. $GOROOT/misc/vim/update.sh or cd misc; vim/update.sh or cd misc/vim; ./update.sh.
The script also ensures that the autoload and ftplugin subdirs exist, and creates them if they don't yet. Just give it a try!
I would like to configure my bash shell to expand partially entered tree structure like it does emacs "minibuffer-complete" command.
Imagine I have two folders, foo1 and foo2. foo1 contains a subfolder sub1, and foo2 contains subfolder wow. So I have:
foo1/sub1/
foo2/wow/
Now when opening a file in emacs if I type
f/w
and press TAB it will automatically expand it to "foo1/wow/".
I would like to have a similar functionality in bash. Any ideas?
Whilst I don't know how to do this in bash, or even if it's possible, I know that if you change your shell to zsh, it can be done.
It's not enabled by default, and I'm not sure how to enable it either, but I use the zsh grml config, which enables the kind of expansion you're talking about.
Zsh, especially combined with said config, also has many other helpful features.
If you're not willing to change shell, then this isn't a helpful answer I'm afraid.
you can have it the other way around, using emacs M-x shell command. It open a Shell buffer with an autocompletion like in the minibuffer
Disclosure: I am the author of the project
I have written the completion functions necessary to enable such completion in bash: https://github.com/sio/bash-complete-partial-path
Hope you'll find this project useful
I would like to know if there is a (simple) solution to the following issue:
When I log in with ssh to a specific host, I would like to automatically execute a (bash)script on that host. This way I could -for example- load my aliases on that host.
Definitively the bashrc script is not executed; The ssh configuration files do not seem to help in this issue either.
Any suggestions?
Thanks in advance!
BTW: The host is running on Gentoo
If .bashrc isn't being run, try .profile, which has a similar function. Different shells use different startup scripts at different times, so knowing when to run things is useful.
On many systems where you have a choice of which shell to use, you are put through ~/.profile only. This way there is no need to find out (and no probably wrong guessing) which shell you're running in and which profile to actually load (.bashrc, .cshrc, .kshrc etc.) and which ones to avoid loading.
The easiest solution in your case would be to create a link (a symbolic one if you prefer visibility) to your favourite shell's startup script as in ln -s ~/.bashrc ~/.profile. If you don't intend to ever using anything other than bash, you're set.