Tag Info

Hot answers tagged

22

With (t)csh, bash or zsh history expansion you could write: vagrant up && !#:0 ssh But, seriously, you wouldn't


13

You could do: eval vagrant\ {'up &&',ssh} but that would not make it easier. You could always make a function doall() { cmd=$1; shift for arg do "$cmd" "$arg" || return done } And then: doall vagrant up ssh


6

The best way, to look at zsh documentation is using info. If you run info zsh, you can use the index (think of a book's index) to locate the section that describes the zmodload command. Press i, then you can enter zmo and press Tab. You'll get straight to the zmodload builtin description which will tell you all about it. In short, zmodload -F loads the ...


5

Not directly an answer but, two alternatives maybe worth looking at (too much for a comment): Alias If you repeatedly use a command, you can put an alias into your ~/.bashrc alias vassh="vagrant up && vagrant ssh" Command line history Ctrl+R let's you search your previous commands. This will be much faster than using variables...


4

In a shell command like PATH=~/bin:/opt/texbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games the tilde is expanded to your home directory when the shell command is executed. Thus the resulting value of PATH is something like /home/theconjuring/bin:/opt/texbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games. Make sure that the tilde ...


3

You can use -l expansion flag: l:expr::string1::string2: Pad the resulting words on the left. Each word will be truncated if required and placed in a field expr characters wide. The arguments :string1: and :string2: are optional; neither, the first, or both may be given. Note that the same pairs of delimiters must be used for each of ...


3

You only need the grml-zsh-config package like: pacman -S grml-zsh-config ...and maybe to set your default shell to zsh like: chsh -s /usr/bin/zsh [username] You might also want to check what else you can get like: pacman -Ss zsh


2

You may already know zsh-history-substring-search. It does not do preview you have seen, as far as I can tell, but otherwise it seems to be very similar. If you do not know it, it's worth trying. zsh-history-substring-search is closely based in the history search of the fish shell. fish has some pretty advanced features in terms of interaction, certainly ...


2

To add it and also have it available immediately: # In your .bashrc or .bash_profile file, add: newalias() {echo "alias ${1}" >> $HOME/.bash_aliases; source ~/.bash_aliases; } This implies using a .bash_aliases file and having it sourced from .bashrc or .bash_profile, with the line . ~/.bash_aliases Some folks might not have the .bash_aliases ...


2

v=vagrant; $v up && $v ssh That might be close to what you're looking for. Here's a function that - in bash - will print the first word in command position for the current compound command: rc() { $(set -f; unset IFS set -- $(history 1) IFS="(){};|'\\\"&#" set \ $2;IFS=\ ;set -- $* printf %s "$1") "$@"; } ...


2

You can break long lines by escaped newlines, that is \ immediatelly followed by a newline: ls_colors_parsed=${${(@s.:.)LS_COLORS}/(#m)\**=[0-\ 9;]#/${${MATCH/(#m)[0-9;]##/$MATCH=$MATCH=04;$MATC\ H}/\*/'=(#b)($PREFIX:t)(?)*'}} WARNING While you can break a line that way nearly everywhere, there are exceptions. It will not work inside single quoted text ...


2

Beware that ${(l:3::0:)var} will pad with zeros but will also truncate a var that is more than 3 characters long (1234 will be changed to 234). Another alternative is to use typeset -Z3 à la ksh: typeset -Z3 z3 zmv '([0-9]-)(<->)(.jpg)' '$1${${z3::=$2}+}$z3$3' We're using ${${z3::=$2}+} above to trigger the assignment to z3. The next $z3 expands z3 ...


2

The syntax you use in echo **/*(AIE) it for zsh; It does not work for bash, for example. The characters in the () are glob qualifiers; Multiple qualifiers are combined by logical AND - that is, they all ned to apply. So the command above shows filenames that are readable, writable and executable for the group. They have the permissions that are set by ...


1

chsh is the program for configuring your login shell. chsh -l will list the available login shells. It's best to keep an existing shell session open when modifying your login configuration so as to prevent inadvertently locking yourself out! I'm not familiar enough with zsh to tell you what elements of your .bashrc might be problematic to copy over.


1

This is one of Zsh's parameter expansions here applied to $*: ${=spec} Perform word splitting using the rules for SH_WORD_SPLIT during the evaluation of spec, but regardless of whether the parameter appears in double quotes; if the ‘=’ is doubled, turn it off. This forces parameter expansions to be split into separate words before substitution, using IFS as ...


1

This question pushed me to fork zsh-syntax-hightighting and add this feature. I've started from the filetypes project as ramonovski suggested in the comment, but it is very outdated with respect to original zsh-syntax-highlighting, lacks a lot of feature, supports only "256 color codes" in $LS_COLORS, etc. At the end I've decided to write my own functions, ...


1

You could do something like: setopt extendedglob alias 'verbose{{=read -rd "" -u9 _code 9<<-"}}";\ eval "${_code//[[:space:]]#$'\''\n'\''[[:space:]]#}"' verbose{{ ls_colors_parsed=${ ${(@s.:.)LS_COLORS} /(#m)\**=[0-9;]# /${ ${MATCH /(#m)[0-9;]## /$MATCH=$MATCH=04;$MATCH } /\* ...


1

That's actually a nice idea. I would create function: addalias() { echo "alias ${1}" >> $HOME/.bash_aliases } Add this to my .bashrc, logout and login again. The usage is: addalias ..='cd ../../'


1

The option that controls a part of this behavior is menu_complete. So, you need: unsetopt menu_complete (but it appears that oh-my-zsh already does this). If this isn't sufficient, in case oh-my-zsh does anything special, you may also try: zstyle ':completion:*' completer _complete bindkey '\t' expand-or-complete You can also compare the behavior with ...


1

Provided you have execute permissions on the current directory - or on the directory from which you executed your shell script - if you want an absolute path to a directory all you need is cd. Step 10 of cd's spec If the -P option is in effect, the $PWD environment variable shall be set to the string that would be output by pwd -P. If there is ...


1

Use this: "${index}_${lumarr[lum]}" Generally: Interpolate all variables using ${...} notation. Unless you expressly want to use word-splitting, always enclose variable interpolations in double-quoted strings.


1

The top line of less output scrolls out on top because you print a line at the bottom, causing one line of scrolling. That's the \n in your prompt. How to avoid this, and still have two lines? You could write part of the prompt above the mormal command line, instead of using a two line prompt. In a sense, it would be one normal line, and one printed above ...


1

Answering the alternative part of your question, "...help me programm it with updating the list properly": You can directly use the functions that list completion items, update the list, or clear it; That's zle -R. To write out your own "unmanaged" text, there is zle -M. From pinfo zsh: zle -R [ -c ] [ DISPLAY-STRING ] [ STRING ... ] zle -M STRING [ ... ] ...



Only top voted, non community-wiki answers of a minimum length are eligible