commit f4742a16057a7b6e6c78c656182bdfc0b71ebe19
parent 35019d4e81a6e7acfb9ed1ab2a0f652aa919411a
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Mon, 10 Feb 2020 12:48:36 +0100
shell: add some oh-my-zsh defaults
Former-commit-id: dcf9dc160d4811271ebce597319899fbce68c8ec
Diffstat:
3 files changed, 103 insertions(+), 1 deletion(-)
diff --git a/shell/oh-my-zsh-defaults/clipboard.zsh b/shell/oh-my-zsh-defaults/clipboard.zsh
@@ -39,7 +39,7 @@ function clipcopy() {
fi
elif (( $+commands[xsel] )); then
if [[ -z $file ]]; then
- xsel --clipboard --input
+ xsel --clipboard --input
else
cat "$file" | xsel --clipboard --input
fi
diff --git a/shell/oh-my-zsh-defaults/history.zsh b/shell/oh-my-zsh-defaults/history.zsh
@@ -0,0 +1,40 @@
+## History wrapper
+function omz_history {
+ local clear list
+ zparseopts -E c=clear l=list
+
+ if [[ -n "$clear" ]]; then
+ # if -c provided, clobber the history file
+ echo -n >| "$HISTFILE"
+ echo >&2 History file deleted. Reload the session to see its effects.
+ elif [[ -n "$list" ]]; then
+ # if -l provided, run as if calling `fc' directly
+ builtin fc "$@"
+ else
+ # unless a number is provided, show all history events (starting from 1)
+ [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
+ fi
+}
+
+# Timestamp format
+case ${HIST_STAMPS-} in
+ "mm/dd/yyyy") alias history='omz_history -f' ;;
+ "dd.mm.yyyy") alias history='omz_history -E' ;;
+ "yyyy-mm-dd") alias history='omz_history -i' ;;
+ "") alias history='omz_history' ;;
+ *) alias history="omz_history -t '$HIST_STAMPS'" ;;
+esac
+
+## History file configuration
+[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
+HISTSIZE=50000
+SAVEHIST=10000
+
+## History command configuration
+setopt extended_history # record timestamp of command in HISTFILE
+setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
+setopt hist_ignore_dups # ignore duplicated commands history list
+setopt hist_ignore_space # ignore commands that start with space
+setopt hist_verify # show command with history expansion to user before running it
+setopt inc_append_history # add commands to HISTFILE in order of execution
+setopt share_history # share command history data
diff --git a/shell/oh-my-zsh-defaults/keys.zsh b/shell/oh-my-zsh-defaults/keys.zsh
@@ -0,0 +1,62 @@
+if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
+ function zle-line-init() {
+ echoti smkx
+ }
+ function zle-line-finish() {
+ echoti rmkx
+ }
+ zle -N zle-line-init
+ zle -N zle-line-finish
+fi
+
+bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
+if [[ "${terminfo[kpp]}" != "" ]]; then
+ bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
+fi
+if [[ "${terminfo[knp]}" != "" ]]; then
+ bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
+fi
+
+# start typing + [Up-Arrow] - fuzzy find history forward
+if [[ "${terminfo[kcuu1]}" != "" ]]; then
+ autoload -U up-line-or-beginning-search
+ zle -N up-line-or-beginning-search
+ bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
+fi
+# start typing + [Down-Arrow] - fuzzy find history backward
+if [[ "${terminfo[kcud1]}" != "" ]]; then
+ autoload -U down-line-or-beginning-search
+ zle -N down-line-or-beginning-search
+ bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
+fi
+
+if [[ "${terminfo[khome]}" != "" ]]; then
+ bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
+fi
+if [[ "${terminfo[kend]}" != "" ]]; then
+ bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
+fi
+
+bindkey ' ' magic-space # [Space] - do history expansion
+
+if [[ "${terminfo[kcbt]}" != "" ]]; then
+ bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
+fi
+
+bindkey '^?' backward-delete-char # [Backspace] - delete backward
+if [[ "${terminfo[kdch1]}" != "" ]]; then
+ bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
+else
+ bindkey "^[[3~" delete-char
+ bindkey "^[3;5~" delete-char
+ bindkey "\e[3~" delete-char
+fi
+
+# Edit the current command line in $EDITOR
+autoload -U edit-command-line
+zle -N edit-command-line
+bindkey '\C-x\C-e' edit-command-line
+
+# file rename magick
+bindkey "^[m" copy-prev-shell-word
+