Добавлены конфиги tmux и zsh

This commit is contained in:
eKa
2019-09-18 00:17:47 +05:00
commit 7d0a7691c6
882 changed files with 67305 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
Copyright (C) 2014 Bruno Sutic
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,95 @@
# Tmux open
Plugin for opening highlighted selection directly from Tmux copy mode.
Tested and working on Linux, OSX and Cygwin.
### Key bindings
In tmux copy mode:
- `o` - "open" a highlighted selection with the system default program. `open`
for OS X or `xdg-open` for Linux.
- `Ctrl-o` - open a highlighted selection with the `$EDITOR`
- `Shift-s` - search the highlighted selection directly inside a search engine (defaults to google).
### Examples
In copy mode:
- highlight `file.pdf` and press `o` - file will open in the default PDF viewer.
- highlight `file.doc` and press `o` - file will open in system default `.doc`
file viewer.
- highlight `http://example.com` and press `o` - link will be opened in the
default browser.
- highlight `file.txt` and press `Ctrl-o` - file will open in `$EDITOR`.
- highlight `TypeError: 'undefined' is not a function` and press `Shift-s` - the text snipped will be searched directly inside google by default
### Screencast
[![screencast screenshot](/video/screencast_img.png)](http://vimeo.com/102455265)
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
Add plugin to the list of TPM plugins in `.tmux.conf`:
set -g @plugin 'tmux-plugins/tmux-open'
Hit `prefix + I` to fetch the plugin and source it. You should now be able to
use the plugin.
### Manual Installation
Clone the repo:
$ git clone https://github.com/tmux-plugins/tmux-open ~/clone/path
Add this line to the bottom of `.tmux.conf`:
run-shell ~/clone/path/open.tmux
Reload TMUX environment:
# type this in terminal
$ tmux source-file ~/.tmux.conf
You should now be able to use the plugin.
### Configuration
> How can I change the default "o" key binding to something else? For example,
> key "x"?
Put `set -g @open 'x'` in `tmux.conf`.
> How can I change the default "Ctrl-o" key binding to "Ctrl-x"?
Put `set -g @open-editor 'C-x'` in `tmux.conf`.
> How can I change the default search engine to "duckduckgo" or any other one?
Put `set -g @open-S 'https://www.duckduckgo.com/'` in `tmux.conf`
> How can I use multiple search engines?
Put:
```
set -g @open-B 'https://www.bing.com/search?q='
set -g @open-S 'https://www.google.com/search?q='
```
in `tmux.conf`
### Other goodies
`tmux-open` works great with:
- [tmux-copycat](https://github.com/tmux-plugins/tmux-copycat) - a plugin for
regex searches in tmux and fast match selection
- [tmux-yank](https://github.com/tmux-plugins/tmux-yank) - enables copying
highlighted text to system clipboard
### License
[MIT](LICENSE.md)

142
tmux/plugins/tmux-open/open.tmux Executable file
View File

@@ -0,0 +1,142 @@
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/helpers.sh"
default_open_key="o"
open_option="@open"
default_open_editor_key="C-o"
open_editor_option="@open-editor"
open_editor_override="@open-editor-command"
command_exists() {
local command="$1"
type "$command" >/dev/null 2>&1
}
is_osx() {
local platform=$(uname)
[ "$platform" == "Darwin" ]
}
is_cygwin() {
[[ "$(uname)" =~ CYGWIN ]]
}
get_editor_from_the_env_var() {
if [ -z $EDITOR ]; then
# $EDITOR not set, fallback
echo "vi"
else
echo "$EDITOR"
fi
}
command_generator() {
local command_string="$1"
echo "xargs -I {} tmux run-shell -b 'cd #{pane_current_path}; $command_string \"{}\" > /dev/null'"
}
search_command_generator() {
local command_string="$1"
local engine="$2"
echo "xargs -I {} tmux run-shell -b 'cd #{pane_current_path}; $command_string $engine\"{}\" > /dev/null'"
}
generate_open_command() {
if is_osx; then
echo "$(command_generator "open")"
elif is_cygwin; then
echo "$(command_generator "cygstart")"
elif command_exists "xdg-open"; then
echo "$(command_generator "xdg-open")"
else
# error command for Linux machines when 'xdg-open' not installed
"$CURRENT_DIR/scripts/tmux_open_error_message.sh" "xdg-open"
fi
}
generate_open_search_command() {
local engine="$1"
if is_osx; then
echo "$(search_command_generator "open" "$engine")"
elif is_cygwin; then
echo "$(command_generator "cygstart")"
elif command_exists "xdg-open"; then
echo "$(search_command_generator "xdg-open" "$engine")"
else
# error command for Linux machines when 'xdg-open' not installed
"$CURRENT_DIR/scripts/tmux_open_error_message.sh" "xdg-open"
fi
}
# 1. write a command to the terminal, example: 'vim -- some_file.txt'
# 2. invoke the command by pressing enter/C-m
generate_editor_command() {
local environment_editor=$(get_editor_from_the_env_var)
local editor=$(get_tmux_option "$open_editor_override" "$environment_editor")
# vim freezes terminal unless there's the '--' argument. Other editors seem
# to be fine with it (textmate [mate], light table [table]).
echo "xargs -I {} tmux send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'"
}
set_copy_mode_open_bindings() {
local open_command="$(generate_open_command)"
local key_bindings=$(get_tmux_option "$open_option" "$default_open_key")
local key
for key in $key_bindings; do
if tmux-is-at-least 2.4; then
tmux bind-key -T copy-mode-vi "$key" send-keys -X copy-pipe-and-cancel "$open_command"
tmux bind-key -T copy-mode "$key" send-keys -X copy-pipe-and-cancel "$open_command"
else
tmux bind-key -t vi-copy "$key" copy-pipe "$open_command"
tmux bind-key -t emacs-copy "$key" copy-pipe "$open_command"
fi
done
}
set_copy_mode_open_editor_bindings() {
local editor_command="$(generate_editor_command)"
local key_bindings=$(get_tmux_option "$open_editor_option" "$default_open_editor_key")
local key
for key in $key_bindings; do
if tmux-is-at-least 2.4; then
tmux bind-key -T copy-mode-vi "$key" send-keys -X copy-pipe-and-cancel "$editor_command"
tmux bind-key -T copy-mode "$key" send-keys -X copy-pipe-and-cancel "$editor_command"
else
tmux bind-key -t vi-copy "$key" copy-pipe "$editor_command"
tmux bind-key -t emacs-copy "$key" copy-pipe "$editor_command"
fi
done
}
set_copy_mode_open_search_bindings() {
local stored_engine_vars="$(stored_engine_vars)"
local engine_var
local engine
local key
for engine_var in $stored_engine_vars; do
engine="$(get_engine "$engine_var")"
if tmux-is-at-least 2.4; then
tmux bind-key -T copy-mode-vi "$engine_var" send-keys -X copy-pipe-and-cancel "$(generate_open_search_command "$engine")"
tmux bind-key -T copy-mode "$engine_var" send-keys -X copy-pipe-and-cancel "$(generate_open_search_command "$engine")"
else
tmux bind-key -t vi-copy "$engine_var" copy-pipe "$(generate_open_search_command "$engine")"
tmux bind-key -t emacs-copy "$engine_var" copy-pipe "$(generate_open_search_command "$engine")"
fi
done
}
main() {
set_copy_mode_open_bindings
set_copy_mode_open_editor_bindings
set_copy_mode_open_search_bindings
}
main