bashisms replacing zoomer shell
This commit is contained in:
parent
1280d2360d
commit
b4a4d90ac8
120
bash/.config/bash/prompt
Normal file
120
bash/.config/bash/prompt
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Source: https://github.com/mathiasbynens/dotfiles/
|
||||||
|
|
||||||
|
# Shell prompt based on the Solarized Dark theme.
|
||||||
|
# Screenshot: http://i.imgur.com/EkEtphC.png
|
||||||
|
# Heavily inspired by @necolas’s prompt: https://github.com/necolas/dotfiles
|
||||||
|
# iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing.
|
||||||
|
|
||||||
|
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
|
||||||
|
export TERM='gnome-256color';
|
||||||
|
elif infocmp xterm-256color >/dev/null 2>&1; then
|
||||||
|
export TERM='xterm-256color';
|
||||||
|
fi;
|
||||||
|
|
||||||
|
prompt_git() {
|
||||||
|
local s='';
|
||||||
|
local branchName='';
|
||||||
|
|
||||||
|
# Check if the current directory is in a Git repository.
|
||||||
|
git rev-parse --is-inside-work-tree &>/dev/null || return;
|
||||||
|
|
||||||
|
# Check for what branch we’re on.
|
||||||
|
# Get the short symbolic ref. If HEAD isn’t a symbolic ref, get a
|
||||||
|
# tracking remote branch or tag. Otherwise, get the
|
||||||
|
# short SHA for the latest commit, or give up.
|
||||||
|
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
|
||||||
|
git describe --all --exact-match HEAD 2> /dev/null || \
|
||||||
|
git rev-parse --short HEAD 2> /dev/null || \
|
||||||
|
echo '(unknown)')";
|
||||||
|
|
||||||
|
# Early exit for Chromium & Blink repo, as the dirty check takes too long.
|
||||||
|
# Thanks, @paulirish!
|
||||||
|
# https://github.com/paulirish/dotfiles/blob/dd33151f/.bash_prompt#L110-L123
|
||||||
|
repoUrl="$(git config --get remote.origin.url)";
|
||||||
|
if grep -q 'chromium/src.git' <<< "${repoUrl}"; then
|
||||||
|
s+='*';
|
||||||
|
else
|
||||||
|
# Check for uncommitted changes in the index.
|
||||||
|
if ! $(git diff --quiet --ignore-submodules --cached); then
|
||||||
|
s+='+';
|
||||||
|
fi;
|
||||||
|
# Check for unstaged changes.
|
||||||
|
if ! $(git diff-files --quiet --ignore-submodules --); then
|
||||||
|
s+='!';
|
||||||
|
fi;
|
||||||
|
# Check for untracked files.
|
||||||
|
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
|
||||||
|
s+='?';
|
||||||
|
fi;
|
||||||
|
# Check for stashed files.
|
||||||
|
if $(git rev-parse --verify refs/stash &>/dev/null); then
|
||||||
|
s+='$';
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
[ -n "${s}" ] && s=" [${s}]";
|
||||||
|
|
||||||
|
echo -e "${1}${branchName}${2}${s}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if tput setaf 1 &> /dev/null; then
|
||||||
|
tput sgr0; # reset colors
|
||||||
|
bold=$(tput bold);
|
||||||
|
reset=$(tput sgr0);
|
||||||
|
# Solarized colors, taken from http://git.io/solarized-colors.
|
||||||
|
black=$(tput setaf 0);
|
||||||
|
blue=$(tput setaf 33);
|
||||||
|
cyan=$(tput setaf 37);
|
||||||
|
green=$(tput setaf 64);
|
||||||
|
orange=$(tput setaf 166);
|
||||||
|
purple=$(tput setaf 125);
|
||||||
|
red=$(tput setaf 124);
|
||||||
|
violet=$(tput setaf 61);
|
||||||
|
white=$(tput setaf 15);
|
||||||
|
yellow=$(tput setaf 136);
|
||||||
|
else
|
||||||
|
bold='';
|
||||||
|
reset="\e[0m";
|
||||||
|
black="\e[1;30m";
|
||||||
|
blue="\e[1;34m";
|
||||||
|
cyan="\e[1;36m";
|
||||||
|
green="\e[1;32m";
|
||||||
|
orange="\e[1;33m";
|
||||||
|
purple="\e[1;35m";
|
||||||
|
red="\e[1;31m";
|
||||||
|
violet="\e[1;35m";
|
||||||
|
white="\e[1;37m";
|
||||||
|
yellow="\e[1;33m";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Highlight the user name when logged in as root.
|
||||||
|
if [[ "${USER}" == "root" ]]; then
|
||||||
|
userStyle="${red}";
|
||||||
|
else
|
||||||
|
userStyle="${orange}";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Highlight the hostname when connected via SSH.
|
||||||
|
if [[ "${SSH_TTY}" ]]; then
|
||||||
|
hostStyle="${bold}${red}";
|
||||||
|
else
|
||||||
|
hostStyle="${yellow}";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Set the terminal title and prompt.
|
||||||
|
PS1="\[\033]0;\W\007\]"; # working directory base name
|
||||||
|
PS1+="\[${bold}\]\n"; # newline
|
||||||
|
PS1+="\[${userStyle}\]\u"; # username
|
||||||
|
PS1+="\[${white}\] at ";
|
||||||
|
PS1+="\[${hostStyle}\]\h"; # host
|
||||||
|
PS1+="\[${white}\] in ";
|
||||||
|
PS1+="\[${green}\]\w"; # working directory full path
|
||||||
|
PS1+="\$(prompt_git \"\[${white}\] on \[${violet}\]\" \"\[${blue}\]\")"; # Git repository details
|
||||||
|
PS1+="\n";
|
||||||
|
PS1+="\[${white}\]\$ \[${reset}\]"; # `$` (and reset color)
|
||||||
|
export PS1;
|
||||||
|
|
||||||
|
PS2="\[${yellow}\]→ \[${reset}\]";
|
||||||
|
export PS2;
|
42
bash/.config/bash/rc
Normal file
42
bash/.config/bash/rc
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Mostly copied from: https://github.com/mathiasbynens/dotfiles/
|
||||||
|
|
||||||
|
# Bash-specific:
|
||||||
|
[ -f ~/.config/bash/prompt ] && source ~/.config/bash/prompt
|
||||||
|
|
||||||
|
# Case-insensitive globbing (used in pathname expansion)
|
||||||
|
shopt -s nocaseglob;
|
||||||
|
|
||||||
|
# Append to the Bash history file, rather than overwriting it
|
||||||
|
shopt -s histappend;
|
||||||
|
|
||||||
|
# Autocorrect typos in path names when using `cd`
|
||||||
|
shopt -s cdspell;
|
||||||
|
|
||||||
|
# Enable some Bash 4 features when possible:
|
||||||
|
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
|
||||||
|
# * Recursive globbing, e.g. `echo **/*.txt`
|
||||||
|
for option in autocd globstar; do
|
||||||
|
shopt -s "$option" 2> /dev/null;
|
||||||
|
done;
|
||||||
|
|
||||||
|
# Add tab completion for many Bash commands
|
||||||
|
if which brew &> /dev/null && [ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]; then
|
||||||
|
# Ensure existing Homebrew v1 completions continue to work
|
||||||
|
export BASH_COMPLETION_COMPAT_DIR="$(brew --prefix)/etc/bash_completion.d";
|
||||||
|
source "$(brew --prefix)/etc/profile.d/bash_completion.sh";
|
||||||
|
elif [ -f /etc/bash_completion ]; then
|
||||||
|
source /etc/bash_completion;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Enable tab completion for `g` by marking it as an alias for `git`
|
||||||
|
if type _git &> /dev/null; then
|
||||||
|
complete -o default -o nospace -F _git g;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
|
||||||
|
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh;
|
||||||
|
|
||||||
|
# Add tab completion for `defaults read|write NSGlobalDomain`
|
||||||
|
# You could just use `-g` instead, but I like being explicit
|
||||||
|
complete -W "NSGlobalDomain" defaults;
|
@ -29,6 +29,3 @@ export PSQLRC="${XDG_CONFIG_HOME:-$HOME/.config}/psql/rc"
|
|||||||
|
|
||||||
# Wget config file
|
# Wget config file
|
||||||
export WGETRC="${XDG_CONFIG_HOME:-$HOME/.config}/wget/rc"
|
export WGETRC="${XDG_CONFIG_HOME:-$HOME/.config}/wget/rc"
|
||||||
|
|
||||||
# ZSH directory
|
|
||||||
export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
|
|
||||||
|
@ -7,3 +7,5 @@ for file in ~/.config/shell/{path,exports,aliases,functions,extra}; do
|
|||||||
[ -r "$file" ] && [ -f "$file" ] && source "$file";
|
[ -r "$file" ] && [ -f "$file" ] && source "$file";
|
||||||
done;
|
done;
|
||||||
unset file;
|
unset file;
|
||||||
|
|
||||||
|
source ~/.config/bash/rc
|
||||||
|
71
zsh/.zshrc
71
zsh/.zshrc
@ -1,71 +0,0 @@
|
|||||||
# Luke's config for the Zoomer Shell
|
|
||||||
# Source (mainly): https://github.com/LukeSmithxyz/voidrice/
|
|
||||||
|
|
||||||
# Enable colors and change prompt:
|
|
||||||
autoload -U colors && colors # Load colors
|
|
||||||
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
|
|
||||||
setopt autocd # Automatically cd into typed directory.
|
|
||||||
stty stop undef # Disable ctrl-s to freeze terminal.
|
|
||||||
setopt interactive_comments
|
|
||||||
|
|
||||||
# History in cache directory:
|
|
||||||
HISTSIZE=10000000
|
|
||||||
SAVEHIST=10000000
|
|
||||||
|
|
||||||
# Basic auto/tab complete:
|
|
||||||
autoload -U compinit
|
|
||||||
zstyle ':completion:*' menu select
|
|
||||||
zmodload zsh/complist
|
|
||||||
compinit
|
|
||||||
_comp_options+=(globdots) # Include hidden files.
|
|
||||||
|
|
||||||
# vi mode
|
|
||||||
bindkey -v
|
|
||||||
export KEYTIMEOUT=1
|
|
||||||
|
|
||||||
# Use vim keys in tab complete menu:
|
|
||||||
bindkey -M menuselect 'h' vi-backward-char
|
|
||||||
bindkey -M menuselect 'k' vi-up-line-or-history
|
|
||||||
bindkey -M menuselect 'l' vi-forward-char
|
|
||||||
bindkey -M menuselect 'j' vi-down-line-or-history
|
|
||||||
bindkey -v '^?' backward-delete-char
|
|
||||||
|
|
||||||
# Change cursor shape for different vi modes.
|
|
||||||
function zle-keymap-select () {
|
|
||||||
case $KEYMAP in
|
|
||||||
vicmd) echo -ne '\e[1 q';; # block
|
|
||||||
viins|main) echo -ne '\e[5 q';; # beam
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
zle -N zle-keymap-select
|
|
||||||
zle-line-init() {
|
|
||||||
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
|
|
||||||
echo -ne "\e[5 q"
|
|
||||||
}
|
|
||||||
zle -N zle-line-init
|
|
||||||
echo -ne '\e[5 q' # Use beam shape cursor on startup.
|
|
||||||
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
|
|
||||||
|
|
||||||
bindkey -s '^a' 'bc -lq\n'
|
|
||||||
|
|
||||||
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
|
|
||||||
|
|
||||||
bindkey '^[[P' delete-char
|
|
||||||
|
|
||||||
# Edit line in vim with ctrl-e:
|
|
||||||
autoload edit-command-line; zle -N edit-command-line
|
|
||||||
bindkey '^e' edit-command-line
|
|
||||||
|
|
||||||
|
|
||||||
# Custom
|
|
||||||
# Activate history search based upon what has already been entered at the prompt,
|
|
||||||
# and always put cursor at the end of the line:
|
|
||||||
autoload -U history-search-end
|
|
||||||
zle -N history-beginning-search-backward-end history-search-end
|
|
||||||
zle -N history-beginning-search-forward-end history-search-end
|
|
||||||
bindkey "^[[A" history-beginning-search-backward-end
|
|
||||||
bindkey "^[[B" history-beginning-search-forward-end
|
|
||||||
|
|
||||||
|
|
||||||
# Load syntax highlighting; should be last.
|
|
||||||
source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null
|
|
Loading…
Reference in New Issue
Block a user