mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-16 23:37:55 +08:00
Compare commits
8 Commits
3bb5e97762
...
95a06f3927
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95a06f3927 | ||
|
|
3f34ce4da4 | ||
|
|
e5d206c8c8 | ||
|
|
0e232d4853 | ||
|
|
90bdb8a156 | ||
|
|
9d556cd545 | ||
|
|
040aadf7c4 | ||
|
|
e8716cb570 |
@ -29,7 +29,7 @@ function emotty() {
|
||||
# Parse tty number via prompt expansion. %l equals:
|
||||
# - N if tty = /dev/ttyN
|
||||
# - pts/N if tty = /dev/pts/N
|
||||
local tty = ${${(%):-%l}##pts/}
|
||||
local tty=${${(%):-%l}##pts/}
|
||||
# Normalize it to an emotty set index
|
||||
(( tty = (tty % ${#${=emotty}}) + 1 ))
|
||||
|
||||
|
||||
@ -73,9 +73,9 @@ function _fossil_prompt () {
|
||||
local is_prompt=`echo $PROMPT | grep git`
|
||||
|
||||
if [ "$is_prompt" = "" ]; then
|
||||
export RPROMPT="$_rprompt"'$(fossil_prompt_info)'
|
||||
RPROMPT="$_rprompt"'$(fossil_prompt_info)'
|
||||
else
|
||||
export PROMPT="$_prompt"'$(fossil_prompt_info) '
|
||||
PROMPT="$_prompt"'$(fossil_prompt_info) '
|
||||
fi
|
||||
|
||||
_FOSSIL_PROMPT="1"
|
||||
|
||||
@ -64,11 +64,21 @@ function setup_using_debian_package() {
|
||||
# NOTE: There is no need to configure PATH for debian package, all binaries
|
||||
# are installed to /usr/bin by default
|
||||
|
||||
# Determine completion file path: first bullseye/sid, then buster/stretch
|
||||
local completions="/usr/share/doc/fzf/examples/completion.zsh"
|
||||
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
|
||||
local completions key_bindings
|
||||
|
||||
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
|
||||
case $PREFIX in
|
||||
*com.termux*)
|
||||
# Support Termux package
|
||||
completions="${PREFIX}/share/fzf/completion.zsh"
|
||||
key_bindings="${PREFIX}/share/fzf/key-bindings.zsh"
|
||||
;;
|
||||
*)
|
||||
# Determine completion file path: first bullseye/sid, then buster/stretch
|
||||
completions="/usr/share/doc/fzf/examples/completion.zsh"
|
||||
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
|
||||
key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Auto-completion
|
||||
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||
|
||||
@ -124,6 +124,7 @@ plugins=(... git)
|
||||
| grbd | git rebase develop |
|
||||
| grbi | git rebase -i |
|
||||
| grbm | git rebase $(git_main_branch) |
|
||||
| grbo | git rebase --onto |
|
||||
| grbs | git rebase --skip |
|
||||
| grev | git revert |
|
||||
| grh | git reset |
|
||||
|
||||
@ -224,6 +224,7 @@ alias grbc='git rebase --continue'
|
||||
alias grbd='git rebase develop'
|
||||
alias grbi='git rebase -i'
|
||||
alias grbm='git rebase $(git_main_branch)'
|
||||
alias grbo='git rebase --onto'
|
||||
alias grbs='git rebase --skip'
|
||||
alias grev='git revert'
|
||||
alias grh='git reset'
|
||||
|
||||
@ -9,7 +9,7 @@ To enable it, add `ssh-agent` to your plugins:
|
||||
plugins=(... ssh-agent)
|
||||
```
|
||||
|
||||
## Instructions
|
||||
## Settings
|
||||
|
||||
**IMPORTANT: put these settings _before_ the line that sources oh-my-zsh**
|
||||
|
||||
@ -19,12 +19,16 @@ To enable **agent forwarding support** add the following to your zshrc file:
|
||||
zstyle :omz:plugins:ssh-agent agent-forwarding on
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
To **load multiple identities** use the `identities` style, For example:
|
||||
|
||||
```zsh
|
||||
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
To **set the maximum lifetime of the identities**, use the `lifetime` style.
|
||||
The lifetime may be specified in seconds or as described in sshd_config(5)
|
||||
(see _TIME FORMATS_). If left unspecified, the default lifetime is forever.
|
||||
@ -33,6 +37,24 @@ The lifetime may be specified in seconds or as described in sshd_config(5)
|
||||
zstyle :omz:plugins:ssh-agent lifetime 4h
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
To **pass arguments to the `ssh-add` command** that adds the identities on startup,
|
||||
use the `ssh-add-args` setting. You can pass multiple arguments separated by spaces:
|
||||
|
||||
```zsh
|
||||
zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
|
||||
```
|
||||
|
||||
These will then be passed the the `ssh-add` call as if written directly. The example
|
||||
above will turn into:
|
||||
|
||||
```zsh
|
||||
ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
|
||||
```
|
||||
|
||||
For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
|
||||
|
||||
## Credits
|
||||
|
||||
Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
|
||||
|
||||
@ -48,7 +48,9 @@ function _add_identities() {
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -n "$not_loaded" ]] && ssh-add ${^not_loaded}
|
||||
local args
|
||||
zstyle -a :omz:plugins:ssh-agent ssh-add-args args
|
||||
[[ -n "$not_loaded" ]] && ssh-add "${args[@]}" ${^not_loaded}
|
||||
}
|
||||
|
||||
# Get the filename to store/lookup the environment from
|
||||
|
||||
@ -50,13 +50,17 @@ zle -N zle-keymap-select
|
||||
# These "echoti" statements were originally set in lib/key-bindings.zsh
|
||||
# Not sure the best way to extend without overriding.
|
||||
function zle-line-init() {
|
||||
local prev_vi_keymap
|
||||
prev_vi_keymap="${VI_KEYMAP:-}"
|
||||
typeset -g VI_KEYMAP=main
|
||||
[[ "$prev_vi_keymap" != 'main' ]] && [[ "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:-}" = true ]] && zle reset-prompt
|
||||
(( ! ${+terminfo[smkx]} )) || echoti smkx
|
||||
_vi-mode-set-cursor-shape-for-keymap "${VI_KEYMAP}"
|
||||
}
|
||||
zle -N zle-line-init
|
||||
|
||||
function zle-line-finish() {
|
||||
typeset -g VI_KEYMAP=main
|
||||
(( ! ${+terminfo[rmkx]} )) || echoti rmkx
|
||||
_vi-mode-set-cursor-shape-for-keymap default
|
||||
}
|
||||
|
||||
@ -57,15 +57,16 @@ command_exists() {
|
||||
}
|
||||
|
||||
fmt_error() {
|
||||
echo ${RED}"Error: $@"${RESET} >&2
|
||||
printf '%sError: %s%s\n' "$BOLD$RED" "$*" "$RESET" >&2
|
||||
}
|
||||
|
||||
fmt_underline() {
|
||||
echo "$(printf '\033[4m')$@$(printf '\033[24m')"
|
||||
printf '\033[4m%s\033[24m\n' "$*"
|
||||
}
|
||||
|
||||
fmt_code() {
|
||||
echo "\`$(printf '\033[38;5;247m')$@${RESET}\`"
|
||||
# shellcheck disable=SC2016 # backtic in single-quote
|
||||
printf '`\033[38;5;247m%s%s`\n' "$*" "$RESET"
|
||||
}
|
||||
|
||||
setup_color() {
|
||||
@ -102,7 +103,8 @@ setup_ohmyzsh() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
|
||||
ostype=$(uname)
|
||||
if [ -z "${ostype%CYGWIN*}" ] && git --version | grep -q msysgit; then
|
||||
fmt_error "Windows/MSYS Git is not supported on Cygwin"
|
||||
fmt_error "Make sure the Cygwin git package is installed and is first on the \$PATH"
|
||||
exit 1
|
||||
@ -130,7 +132,7 @@ setup_zshrc() {
|
||||
OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
|
||||
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
|
||||
# Skip this if the user doesn't want to replace an existing .zshrc
|
||||
if [ $KEEP_ZSHRC = yes ]; then
|
||||
if [ "$KEEP_ZSHRC" = yes ]; then
|
||||
echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
|
||||
return
|
||||
fi
|
||||
@ -162,7 +164,7 @@ export ZSH=\"$ZSH\"
|
||||
|
||||
setup_shell() {
|
||||
# Skip setup if the user wants or stdin is closed (not running interactively).
|
||||
if [ $CHSH = no ]; then
|
||||
if [ "$CHSH" = no ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
@ -183,8 +185,9 @@ EOF
|
||||
echo "${BLUE}Time to change your default shell to zsh:${RESET}"
|
||||
|
||||
# Prompt for user choice on changing the default login shell
|
||||
printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} "
|
||||
read opt
|
||||
printf '%sDo you want to change your default shell to zsh? [Y/n]%s ' \
|
||||
"$YELLOW" "$RESET"
|
||||
read -r opt
|
||||
case $opt in
|
||||
y*|Y*|"") echo "Changing the shell..." ;;
|
||||
n*|N*) echo "Shell change skipped."; return ;;
|
||||
@ -211,7 +214,7 @@ EOF
|
||||
# Get the path to the right zsh binary
|
||||
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
|
||||
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
|
||||
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
|
||||
if ! zsh=$(command -v zsh) || ! grep -qx "$zsh" "$shells_file"; then
|
||||
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
|
||||
fmt_error "no zsh binary found or not present in '$shells_file'"
|
||||
fmt_error "change your default shell manually."
|
||||
@ -222,7 +225,7 @@ EOF
|
||||
|
||||
# We're going to change the default shell, so back up the current one
|
||||
if [ -n "$SHELL" ]; then
|
||||
echo $SHELL > ~/.shell.pre-oh-my-zsh
|
||||
echo "$SHELL" > ~/.shell.pre-oh-my-zsh
|
||||
else
|
||||
grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
|
||||
fi
|
||||
@ -288,7 +291,7 @@ EOF
|
||||
setup_zshrc
|
||||
setup_shell
|
||||
|
||||
printf "$GREEN"
|
||||
printf %s "$GREEN"
|
||||
cat <<'EOF'
|
||||
__ __
|
||||
____ / /_ ____ ___ __ __ ____ _____/ /_
|
||||
@ -307,7 +310,7 @@ Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugin
|
||||
• Get stickers, shirts, coffee mugs and other swag: $(fmt_underline https://shop.planetargon.com/collections/oh-my-zsh)
|
||||
|
||||
EOF
|
||||
printf "$RESET"
|
||||
printf %s "$RESET"
|
||||
|
||||
if [ $RUNZSH = no ]; then
|
||||
echo "${YELLOW}Run zsh to try it out.${RESET}"
|
||||
|
||||
@ -9,20 +9,20 @@ if [ -d ~/.oh-my-zsh ]; then
|
||||
rm -rf ~/.oh-my-zsh
|
||||
fi
|
||||
|
||||
if [ -e ~/.zshrc ]; then
|
||||
ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
|
||||
echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
|
||||
mv ~/.zshrc "${ZSHRC_SAVE}"
|
||||
fi
|
||||
|
||||
echo "Looking for original zsh config..."
|
||||
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
|
||||
if [ -e "$ZSHRC_ORIG" ]; then
|
||||
echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
|
||||
|
||||
if [ -e ~/.zshrc ]; then
|
||||
ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
|
||||
echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
|
||||
mv ~/.zshrc "${ZSHRC_SAVE}"
|
||||
fi
|
||||
|
||||
mv "$ZSHRC_ORIG" ~/.zshrc
|
||||
|
||||
echo "Your original zsh config was restored."
|
||||
else
|
||||
echo "No original zsh config found"
|
||||
fi
|
||||
|
||||
if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user