I have a command xssh that is a wrapper of the original ssh command. I need a Zsh completion for this command, and the completion rules are exactly the same as zsh. So what I add a the following to the _xssh file
#compdef xssh
compdef xssh=ssh
I can load the completion for the command, but the problem is that if it's the first time when I use the xssh command in a terminal and type <TAB>, I have to type <TAB> twice so that the completion can start to work. For example, I have to type xssh ho<TAB><TAB> to get xssh hostname. But after that, I only have to type xssh ho<TAB> to get xssh hostname (hostname is unique in my .ssh/config file). So do you have any idea how to fix this?
This situation will not happen if I write the completion from scratch as I did for my other commands
I had same issue.
I had a completion file called _gd in my fpath, which looked like this:
#compdef gd
function _gd {
... my code ...
_describe gd list
}
First time I started a shell it needed 2 tab presses to work, then after that just a single one.
To fix it all I had to do was remove the function {} part, so it now looks just like
#compdef gd
...mycode...
_describe gd list
Related
I understand, that when I start typing that fish can give me either auto-suggestions or tab completion.
But: I also noticed that sometimes I get updates to my command line while typing. Example: I have a command a lengthy command line to enable some tooling of mine, lets say it looks like:
python3 whatever.py -bla -blub --property fubber:blub
I start typing "py2" and fish suggests
python3 whatever.py -bla -blub --property fubber:blub
OK. So I use alt-left arrow to accept up to
python3 whatever.py -bla -blub
and now I start typing --property ( not accepting, typing that word ). Thing is: as soon as typed the last char (y) from property fish will somehow insert content into command line. Worse: it also happens frequently, that the whole isn't showing correctly any more in my iterm session - I actually have no way of seeing the exact current command before hitting enter.
I know that the above isn't exactly an MCVE - but I can't disclose my actual command here, and I was unable to create that MCVE. In that sense, my question boils down to: which events make the fish shell insert content into the "current" command?
For completness:
I am running fish, version 2.7 on Mac Os 10.13.3, installed via brew
default bindings
I am sure that just pressed "y", no modifier key added to that
But I am also unable to repro at this point in time. So, although I am very sure that I didn't dream this up, I consider this to be a strange hick-up for the moment that hopefully stopped bugging me for now.
I'm trying to find a way to jump to the previous prompt in iTerm using tmux. Can I set a binding to search a unique phrase within my prompt?
So to expand on Yuriy's answer. Inside your terminal you can run the following commands:
tmux copy-mode ; tmux send -X search-backward 'Example'
That should put your current tmux pane into copy-mode and then initiate a search for 'Example'. Now instead of typing that every time we want to search we'll create a shell script(lets say /tmp/search.sh) and then a tmux binding to that script
Contents of /tmp/search.sh
#!/usr/bin/env bash
tmux copy-mode ; tmux send -X search-backward 'These'
make sure you make it executable with chmod +x /tmp/search.sh. At this point you can test that it works by simply calling the script from your tmux session. To add it as a binding you can something akin to the following to your ~/.tmux.conf file:
bind p run-shell "bash /tmp/search.sh"
Make sure you source refresh the configuration in your tmux session and your new binding should initiate the search.
The canonical way of doing this is write a bash script to issue the commands back to your tmux.
But I'd like to suggest a mod that allows way more flexible scripting: http://ershov.github.io/tmux/ (I'm the author)
Using this mod, your problem can be solved this way:
bind p copy-mode ";" tcl {
set s [copy-mode-screenline -ex [copy-mode-get-cx]]
cursor-up
send-keys "?" "\x15$s"
}
This will read the current line from the beginning up to the cursor position and search for the previous occurrence of it.
The key 'p' can be changed to your preference.
just setup zsh with oh-my-zsh on Raspberry Pi
After every command, it reprints the command I typed. For example...
pi#raspberrypi ~>> ls
;lsDesktop ocr_pi.png python_games
Two causes of stuff like this are:
(most likely) You have something in a command execution hook causing this. See this for details http://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions
try
which precmd
which preexec
which zshaddhistory
or if they did it using the arrays to hold hooks:
echo $precmd_functions
echo $preexec_functions
echo $zshaddhistory_functions
or any of the hooks described in that page with '_functions' appended to it.
There is likely some buggy function bound to get executed right before you run a command or when you save your history etc. To turn them off (other than fixing oh-my-zsh or your setup of it) Call unset precmd_functions to unset an array of functions, or unfunction precmd.
(very unlikely) you may have something funny getting executed in your prompt (unlikely but possible). Try export PROMPT='foo ' or unsetting PS1.
I keep on getting this warning when I run iex using elixir-mode-iex from Emacs:
Warning: could not run smart terminal, falling back to dumb one
I think that this just means that I don't get tab completion, which I'm fine with. But I'd like a smart terminal if it's possible with elixir-mode in Emacs.
elixir-mode-iex uses the comint-mode major mode to interactive with iex. That also means that it's acting just like a dumb terminal (doesn't have the ability to process special escape sequences etc see here).
As a workaround you just could use term which sends any key press directly to the subprocess itself. You could write a function like the following:
(defun my-elixir-iex ()
(interactive)
(term "iex"))
I'm working on an iex Alchemist.el integration, which brings functionality like Inf-Ruby has. But until it's done try to just use iex via term
Cheers
Samuel
It looks like that warning occurs when IEX can't find tty support. You can enable tty mode in emacs by invoking it with -nw.
I have problem with setting start module and function in "Run configuration"
I'm doing it that way:
"Run -> Run Configuration" and in "start" section I'm setting
Module: mod,
Function: hello
my code:
-module(mod).
-export([hello/0]).
hello()-> io:format("42").
Now, when I hit "Run" I would like mod:hello() to be execute automatically, but it doesn't work.
What am I doing wrong?
The code does get executed...
When you hit "Run", mod:hello() does get executed. The thing is, the execution of mod:hello() is meant for system initialization, like loading library code and initializing looping states. The side effect of mod:hello(), which is the string "42" as stdout will not be reflected in your Eclipse console. To prove my point, we can create some more explicit and more persistent side effects, like creating a file in the file system called output_file.txt. Change mod.erl to something like this:
-module(mod).
-export([hello/0]).
hello() ->
os:cmd("touch output_file.txt").
Hit "Run", and you will find a output_file.txt file being created under your workspace directory. This is an evidence for the execution of mod:hello().
To achieve what you want...
In an Unix shell:
$ erlc mod.erl
$ erl -noshell -s mod hello -s init stop
42
Depending on what you want to execute, there is an alternative to the answer above: the "live expressions". There is a view with this name in the same place as the console, where you can enter an expression and enable it for evaluation every time a module is recompiled.
This works nicely for expression that aren't heavy to evaluate and that are without side effects, can be used as a form of alternative to having a test suite.