Commit Graph

44 Commits

Author SHA1 Message Date
Marek Dědič bbe54e4e60
lib: use `command` to run rm in upgrade function (#8696) 2020-03-03 13:46:06 +01:00
Marc Cornellà 40b013f5f1 lib: delete upgrade lock in upgrade_oh_my_zsh
Provides a different solution to #8332 and #8333
2020-02-24 20:27:21 +01:00
Marc Cornellà 095d56b5ea Fix WSL check for WSL 2 and simplify nohup in open_command
WSL 2 changes the output of `uname -r`. For instance,

  WSL 1: 4.4.0-18980-Microsoft
  WSL 2: 4.19.67-microsoft-standard

Since WSL 2 lowercases the M, we can match for the rest of the string
which remains lowercase throughout both versions. Another option would
be to match for both upper- and lower-case Ms, like that:

  $(uname -r) = *[Mm]icrosoft*

Fixed use of nohup in open_command where it was only necessary for
xdg-open (and actually harmful for cmd.exe in WSL 2). The current logic
is simpler and more future-proof.
2019-09-19 16:20:02 +02:00
Marc Cornellà 55575b88f9 lib: optimize default and env_default 2019-02-25 23:20:47 +01:00
Marc Cornellà 2c1ff85bb2
core: fix alias_value function
Fixes #5835
2018-08-09 19:49:02 +02:00
sam-lunt 7cba6bb038 Enable passing multiple directories to take (#6900)
* enable passing multiple directories to take

* Update take function

Do not call cd if mkdir fails
2018-07-02 17:05:24 +02:00
Marc Cornellà f898ada8e3 open_command: fix and improve command for WSL
- Add double quotes to command so that the next argument isn't
  interpreted as the title for the start command.

- If the first argument is a valid path, convert it to Windows path
  notation. If `wslpath` fails—because it's a path from inside WSL,
  which cannot be converted to Windows path notation— fail with an
  error code.

  This last circumstance will show an error like so:

    wslpath: path: Result not representable
2018-06-30 21:13:08 +02:00
Marc Cornellà 12086593a4 open_command: simplify code 2018-06-30 21:13:08 +02:00
Marc Cornellà 93d9431890
Check for Microsoft's WSL in open_command (#6751)
This will work only on files and directories in a DrvFs mount, i.e.
that can be translated to a Windows drive path.
For example: /mnt/c/Users/user.

Files and folders inside the LXSS directory can't be handled in
Windows, they must be ONLY used by the WSL subsystem. That's why
you won't be able to open your $HOME directory, for instance.

See https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/
2018-04-24 23:47:26 +02:00
Patrick José Pereira 2a6c40f66f 'lib/functions.zsh: Solve typos'
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2016-12-30 10:34:16 -02:00
Fredrik Fornwall 9772f8e10d Replace /bin/sh with sh for portability (#5291)
This makes things work even on system lacking /bin/sh, such as on
non-rooted Android systems.
2016-08-09 02:39:11 +02:00
Marc Cornellà 584e0a6ef9 Use shwordsplit in open_command() 2015-11-30 21:27:58 +01:00
Marc Cornellà afdfe2391e Add empty string parameter to start command
Otherwise `start` will confuse the first parameter as the title of
a new command prompt if the parameter contains whitespace. That is
because the command to be run will be:

    start "abc def"

which opens a new command prompt window with the title "abc def".
With the added empty string we force the start command to interpret
the passed parameter as the file / command:

    start "" "abc def"

which will be interpreted like `""` is the title and the rest is
the file or command to start.

-------

**NOTE:** this wouldn't be necessary if the start script in msys
was defined differently; that is, if it had the empty string
already incorporated in the script (/usr/bin/start), like so:

```diff
-cmd //c start "${@//&/^&}"
+cmd //c start "" "${@//&/^&}"
```

Notice however that this would make it impossible to use start
setting a different title, so it's probably best to leave it as is.

More info: http://sourceforge.net/p/msys2/tickets/14/

-------

The change `${(z)open_cmd}` is necessary to force zsh to split the
variable by the spaces and interpret it as separate words.

More info: http://zsh.sourceforge.net/FAQ/zshfaq03.html#l17
2015-11-30 21:21:28 +01:00
Mark Ingalls 0a79f1e836 make this work in the git-for-windows SDK
Added an option for the msys value of $OSTYPE
2015-11-30 21:01:15 +01:00
Marc Cornellà fea74b4b34 Fix open_command nohup call
There a syntax error if $cmd_var contains more than one word,
so we drop the current way to prepend nohup and use a simpler
if-else form.
2015-11-29 19:34:10 +01:00
Andrew Janke f0981d564a termsupport: protect subshell with quotes 2015-11-27 15:58:06 +01:00
Marc Cornellà ebfba0e539 Drop the use of nohup on OSX for tmux compatibility
Apparently `nohup` is not needed in OSX, and using it has the side
that it may break under tmux with the error

  nohup: can't detach from console: No such file or directory

For now, this commit only drops the use of `nohup` in OSX. But it
*may* not be necessary under other similar platforms.
2015-11-27 15:40:31 +01:00
Andrew Janke 00eb465830 Merge branch 'master' into fold-terminalapp-plugin-into-termsupport 2015-08-17 20:59:39 -04:00
Andrew Janke 96c34cebae Add a deprecation comment. 2015-08-17 20:51:41 -04:00
Andrew Janke 14b4ba83c3 Move urlencode/urldecode functions to core lib 2015-08-09 16:28:47 -04:00
Marc Cornellà 2d0bfcf818 Implement cross-platform open function open_command()
For now this supports:
- Mac OS X
- Linux (presumably works on all versions)
- Cygwin (Windows)
2015-08-05 00:27:51 +02:00
Fredrik Fornwall dac2a6e27a Replace /usr/bin/env with env
Some environments (such as Android) does not have /usr/bin.
2014-08-20 23:52:05 +02:00
Huang, Tao 217d8f0540 `fc -l 1` instead of `history` in zsh_stats #2501
$HIST_STAMP breaks zsh_stats. see #2501
2014-02-06 17:29:33 +08:00
Robby Russell 1dd9c43e12 Merge pull request #1134 from koraa/pull_req_helpers
Helpers for default variables and alias value access
2013-12-02 23:47:21 -08:00
CHH 5b2ca3875a Improved statistics functions, effect:
1  1124  24.6006%    c
 2  985   21.5583%    git
 3  343   7.50711%    rails
 4  328   7.17881%    cd
 5  314   6.8724%     rspec
 6  257   5.62486%    la
 7  197   4.31167%    rake
 8  154   3.37054%    s
 9  109   2.38564%    ..
10  95    2.07923%    rvm
11  68    1.48829%    guard
12  36    0.787919%   bundle
13  29    0.634712%   ssh
14  28    0.612826%   pry
15  27    0.590939%   open
16  26    0.569052%   middleman
17  26    0.569052%   gem
18  24    0.525279%   rm
19  24    0.525279%   heroku
20  23    0.503392%   nvm
2012-11-14 19:09:13 +08:00
mapc 8f71efc09b Add helper to easily define default values for variables and env variables. 2012-05-29 01:51:50 +02:00
mapc dbef8b1a92 Add helper to get the value of an alias only 2012-05-29 01:49:52 +02:00
Indrajit Raychaudhuri 0b583638ae Fix upgrade and uninstall functions to pick up $ZSH value 2011-12-25 19:53:55 +05:30
Sorin Ionescu 1db6575f14 Added extract plugin. 2011-06-01 20:33:16 -04:00
Robby Russell a81b0171cc Merge pull request #196 from asymmetric/master
Add missing flag to unrar
2011-05-26 01:13:18 -07:00
Renaud (Nel) Morvan faac3ba8fc Refactor window and tab title in tty
Term window title and tab title are now skinable
Tab title can be different from window title (when supported by term)
Default theme is optimized of usuability (no %u@%m: $~ in a 10 char tab)
Cleanup code duplication and add comment for supported terms
On osX it works great on iterm, and is decent once you tweak Terminal pref
Tested under GNU screen, iTerm and Apple Terminal, need to be tested on linux
TODO implement Konsole support (via dbus)
2011-01-30 09:19:47 +01:00
Lorenzo Manacorda fcc7801435 add missing unrar flag 2011-01-24 15:49:49 +01:00
Robin Ramael bcc235e142 Added an option to remove file afterwards. 2011-01-10 17:49:53 +00:00
SuprDewd f0136f2aec Support for more archive formats. 2010-12-25 13:28:16 +00:00
SuprDewd ff0b25b745 Added a function to extract various archives.
Also an alias for the function.
2010-12-24 22:20:57 +00:00
Sven Lito dc12853b0c merging in changes from robby's repo 2010-10-09 19:11:07 +01:00
Brandon Philips aab235f612 functions: fix title() to not match any $TERM
On my linux virtual terminals, where TERM="linux", I was getting
annoying output that was messing up my prompt.

It turns out the title function was always matching on the elif
statement for xterm/rxvt no matter what and the linux vt doesn't know
what to do with the title special control sequence and thus was printing
out garbage.

Through experimentation I figured out that the || inside of the [[ ]]
did not work:

export TERM=linux
$ if [[ $TERM =~ "^xterm" || $TERM == "rxvt" ]]; then echo $TERM; fi
linux

$ if [[ $TERM =~ "^xterm" ]] || [[ $TERM == "rxvt" ]]; then echo $TERM; fi

Signed-off-by: Brandon Philips <brandon@ifup.org>

openSUSE running zsh 4.3.10
2010-10-08 22:55:09 -07:00
Trevor Creech b905630366 Match xterm-color, the default OS X terminal 2010-09-30 21:00:38 -07:00
Robby Russell 89bd2bf317 Moving some rails and osx-specific functions to their corresponding plugin files 2010-06-03 12:55:07 -07:00
Robby Russell 3cf9ab722e Initial implementation of a new plugin system, so that people can managed which aliases/functions they want. 2010-06-03 12:03:26 -07:00
Dale Campbell 90627d3d1c adding quotes to tab() 2009-12-27 21:16:16 -08:00
Robby Russell 2ecc228b23 Adding a function that will open up a ticket in Lighthouse based on the number and there being a URL in a hidden file. 2009-12-16 11:23:41 -08:00
James Cox 8a8a7bafa0 merge upstream 2009-09-23 16:14:04 +01:00
Robby Russell 8debd097fb Moving all zsh config options into a lib/ subdirectory to make way for some upcoming changes to directory structure and configuration options 2009-09-23 07:43:36 -07:00
Renamed from functions.zsh (Browse further)