Split ZSH config into different files.
This commit is contained in:
62
zsh/zsh/aliases.sh
Normal file
62
zsh/zsh/aliases.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
### TRANSLATIONS
|
||||
alias vim="nvim -u $VIMRC"
|
||||
|
||||
### COMMON OPERATIONS
|
||||
alias ll='ls -AlFh'
|
||||
alias la='ls -A'
|
||||
|
||||
alias spm="sudo pacman"
|
||||
|
||||
alias tml="tmux list-sessions"
|
||||
alias tma="tmux ls 2>/dev/null && tmux attach-session || tmux"
|
||||
|
||||
alias clip="xclip -selection clipboard"
|
||||
alias clipo="xclip -out -selection clipboard"
|
||||
|
||||
alias rgrep="grep -r"
|
||||
|
||||
alias vimrc="vim -c ':e \$MYVIMRC'"
|
||||
alias zshrc="vim -c ':e ~/.zshrc' ; source ~/.zshrc"
|
||||
|
||||
alias calc='python3 -ic "from math import *; import cmath"'
|
||||
|
||||
alias le_haxxor_1='clear && dmesg | pv -qL 20'
|
||||
alias le_haxxor_2='clear && hexdump -C /dev/urandom | pv -qlL 2'
|
||||
|
||||
alias b='cd $OLDPWD'
|
||||
|
||||
alias root='sudo -sE'
|
||||
|
||||
### USEFUL DEFAULT OPTIONS
|
||||
alias tmux="tmux -2"
|
||||
|
||||
alias chmod="chmod -c"
|
||||
alias chown="chown -c"
|
||||
|
||||
alias ls="ls --group-directories-first --classify --color=auto"
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
|
||||
alias rm='rm -v'
|
||||
alias cp='cp -vi'
|
||||
alias mv='mv -vi'
|
||||
alias ln='ln -v'
|
||||
|
||||
alias du='du -h'
|
||||
alias df='df -h'
|
||||
|
||||
# show non-printable characters by default
|
||||
alias cat="cat -v"
|
||||
|
||||
### SHORTENING COMMAND NAMES
|
||||
alias cs="cryptsetup"
|
||||
alias v="vim"
|
||||
alias g="git"
|
||||
alias t="tmux"
|
||||
alias c="cd"
|
||||
alias l="ls"
|
||||
alias s="sudo"
|
||||
alias t="tmux"
|
||||
alias cl="clear"
|
||||
124
zsh/zsh/functions.sh
Normal file
124
zsh/zsh/functions.sh
Normal file
@@ -0,0 +1,124 @@
|
||||
_remote() {
|
||||
[[ -n "$SSH_CONNECTION" ]]
|
||||
}
|
||||
|
||||
cd() {
|
||||
builtin cd "$@" && ls
|
||||
}
|
||||
|
||||
mount() {
|
||||
if [[ $# == 0 ]] ; then
|
||||
command mount | column -t
|
||||
else
|
||||
command mount "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
extr()
|
||||
{
|
||||
if [[ -f "$1" ]] ; then
|
||||
case "$1" in
|
||||
*.tar.bz2 ) tar xvjf "$1" ;;
|
||||
*.tar.gz ) tar xvzf "$1" ;;
|
||||
*.tar.xz ) tar xvJf "$1" ;;
|
||||
*.bz2 ) bunzip2 "$1" ;;
|
||||
*.rar ) unrar x "$1" ;;
|
||||
*.gz ) gunzip "$1" ;;
|
||||
*.tar ) tar xvf "$1" ;;
|
||||
*.tbz2 ) tar xvjf "$1" ;;
|
||||
*.tgz ) tar xvzf "$1" ;;
|
||||
*.zip ) unzip "$1" ;;
|
||||
*.Z ) uncompress "$1" ;;
|
||||
*.7z ) 7z x "$1" ;;
|
||||
*)
|
||||
echo "$1 cannot be extracted via $0"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "$1 is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
ruler() {
|
||||
for s in '....^....|' '1234567890'; do
|
||||
w=${#s}
|
||||
str=$(for (( i=1; $i<=$(( ($COLUMNS + $w) / $w )) ; i=$i+1 )); do echo -n $s; done )
|
||||
str=$(echo $str | cut -c -$COLUMNS)
|
||||
echo $str
|
||||
done
|
||||
}
|
||||
|
||||
addext() {
|
||||
[[ -z "$1" ]] || [[ -z "$2" ]] && { echo "Usage: $0 <file> <extension>" ; return }
|
||||
mv "$1" "$1$2"
|
||||
}
|
||||
|
||||
rmext() {
|
||||
[[ -e "$1" ]] && mv -i "$1" "${1%.*}"
|
||||
}
|
||||
|
||||
|
||||
ckwww() {
|
||||
ping -c 3 www.google.com
|
||||
}
|
||||
|
||||
httpcode() {
|
||||
curl http://httpcode.info/$1
|
||||
}
|
||||
|
||||
bak() {
|
||||
[[ -e "$1" ]] && cp -av "$1" "$1.bak"
|
||||
}
|
||||
|
||||
fstab() {
|
||||
# yeah
|
||||
expand /etc/fstab | grep -v '^#' | grep -P '^.+$' | tr -s ' ' | tr ' ' '|' | cat <(grep -P '<.+>' /etc/fstab | cut -f 2- -d ' ' | sed 's/>[^<]*</>|</g') - | column -ts '|'
|
||||
}
|
||||
|
||||
serve() {
|
||||
python3 -m http.server 8800
|
||||
}
|
||||
|
||||
manpdf() {
|
||||
[[ -z "$1" ]] && { printf '%s' >&2 "$(man)" ; return ; }
|
||||
man -t "$1" | ps2pdf - - | zathura -
|
||||
}
|
||||
|
||||
myip4() {
|
||||
curl "http://ipv4.icanhazip.com"
|
||||
}
|
||||
|
||||
myip6() {
|
||||
curl "http://ipv6.icanhazip.com" 2>/dev/null || echo "no ip6"
|
||||
}
|
||||
|
||||
diffdir() {
|
||||
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
|
||||
diff <(cd "$1" && find -type f | sort | xargs md5sum) <(cd "$2" && find -type f | sort | xargs md5sum)
|
||||
}
|
||||
|
||||
bm() {
|
||||
case "$1" in
|
||||
dev)
|
||||
cd "$HOME/development/projects"
|
||||
;;
|
||||
dot)
|
||||
cd "$HOME/dotfiles"
|
||||
;;
|
||||
*)
|
||||
echo "unknown target"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
man() {
|
||||
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
||||
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
||||
LESS_TERMCAP_me=$'\E[0m' \
|
||||
LESS_TERMCAP_se=$'\E[0m' \
|
||||
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
||||
LESS_TERMCAP_ue=$'\E[0m' \
|
||||
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
||||
man "$@"
|
||||
}
|
||||
|
||||
16
zsh/zsh/prompt.sh
Normal file
16
zsh/zsh/prompt.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
setprompt() {
|
||||
setopt prompt_subst
|
||||
|
||||
topstr="%{$fg[green]%}%n@%m%{$fg[white]%} ─ %{%B$fg[yellow]%}%~${vcs_info_msg_0_}%{%b%} %{$fg[white]%}"
|
||||
botstr="%B${PINFO}%#%b "
|
||||
|
||||
if _remote ; then
|
||||
topstr="%{$fg[red]%}[remote]%{$fg[white]%} ${topstr}"
|
||||
fi
|
||||
|
||||
PROMPT="%{$fg[white]%}┌─ ${topstr}
|
||||
└─ ${botstr}"
|
||||
RPROMPT="%{$fg[cyan]%}%*%{$fg[white]%} ─ [%?]"
|
||||
}
|
||||
|
||||
setprompt
|
||||
43
zsh/zsh/shellopts.sh
Normal file
43
zsh/zsh/shellopts.sh
Normal file
@@ -0,0 +1,43 @@
|
||||
setopt EXTENDED_HISTORY
|
||||
setopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt HIST_VERIFY
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt SHARE_HISTORY
|
||||
setopt AUTO_CD
|
||||
setopt APPEND_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt NOHIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt CORRECT
|
||||
setopt RM_STAR_SILENT
|
||||
setopt BG_NICE
|
||||
setopt CHECK_JOBS
|
||||
setopt HUP
|
||||
setopt LONG_LIST_JOBS
|
||||
|
||||
bindkey -e
|
||||
|
||||
autoload -U promptinit
|
||||
promptinit
|
||||
|
||||
autoload -U colors
|
||||
colors
|
||||
|
||||
autoload -U compinit
|
||||
compinit
|
||||
zstyle ':completion:*' menu select
|
||||
setopt completealiases
|
||||
|
||||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '^xe' edit-command-line
|
||||
bindkey '^x^e' edit-command-line
|
||||
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
HISTFILE="$HOME/.zsh_history"
|
||||
|
||||
autoload -Uz vcs_info
|
||||
zstyle ':vcs_info:*' enable git hg
|
||||
zstyle ':vcs_info:*' check-for-changes true
|
||||
zstyle ':vcs_info:git*' formats "%{${fg[cyan]}%}[%{${fg[green]}%}%s%{${fg[cyan]}%}][%{${fg[blue]}%}%r/%S%%{${fg[cyan]}%}][%{${fg[blue]}%}%b%{${fg[yellow]}%}%m%u%c%{${fg[cyan]}%}]%{$reset_color%}"
|
||||
9
zsh/zsh/variables.sh
Normal file
9
zsh/zsh/variables.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
case "$TERM" in
|
||||
urxvt)
|
||||
TERM="rxvt-unicode"
|
||||
;;
|
||||
screen)
|
||||
TERM="screen-256color"
|
||||
;;
|
||||
esac
|
||||
export TERM
|
||||
420
zsh/zshrc
420
zsh/zshrc
@@ -1,413 +1,15 @@
|
||||
[[ -z "$PS1" ]] && return
|
||||
|
||||
### SHELL OPTIONS
|
||||
setopt EXTENDED_HISTORY
|
||||
setopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt HIST_VERIFY
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt SHARE_HISTORY
|
||||
setopt AUTO_CD
|
||||
setopt APPEND_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt NOHIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt CORRECT
|
||||
setopt RM_STAR_SILENT
|
||||
setopt BG_NICE
|
||||
setopt CHECK_JOBS
|
||||
setopt HUP
|
||||
setopt LONG_LIST_JOBS
|
||||
|
||||
# emacs-like keybindings
|
||||
bindkey -e
|
||||
|
||||
autoload -U promptinit
|
||||
promptinit
|
||||
|
||||
autoload -U colors
|
||||
colors
|
||||
|
||||
autoload -U compinit
|
||||
compinit
|
||||
zstyle ':completion:*' menu select
|
||||
setopt completealiases
|
||||
|
||||
autoload -U edit-command-line
|
||||
zle -N edit-command-line
|
||||
bindkey '^xe' edit-command-line
|
||||
bindkey '^x^e' edit-command-line
|
||||
|
||||
|
||||
|
||||
#[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" history-beginning-search-backward
|
||||
#[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" history-beginning-search-forward
|
||||
|
||||
|
||||
#DIRSTACKFILE="$HOME/.cache/zsh/dirs"
|
||||
#if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
|
||||
# dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
|
||||
# [[ -d $dirstack[1] ]] && cd $dirstack[1]
|
||||
#fi
|
||||
#chpwd() {
|
||||
# print -l $PWD ${(u)dirstack} >$DIRSTACKFILE
|
||||
#}
|
||||
#
|
||||
#DIRSTACKSIZE=20
|
||||
#
|
||||
#setopt autopushd pushdsilent pushdtohome
|
||||
#
|
||||
### Remove duplicate entries
|
||||
#setopt pushdignoredups
|
||||
#
|
||||
### This reverts the +/- operators.
|
||||
#setopt pushdminus
|
||||
|
||||
#source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
HISTFILE="$HOME/.zsh_history"
|
||||
|
||||
man() {
|
||||
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
||||
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
||||
LESS_TERMCAP_me=$'\E[0m' \
|
||||
LESS_TERMCAP_se=$'\E[0m' \
|
||||
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
||||
LESS_TERMCAP_ue=$'\E[0m' \
|
||||
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
||||
man "$@"
|
||||
}
|
||||
|
||||
### BOOKMARKS
|
||||
bm() {
|
||||
case "$1" in
|
||||
dev)
|
||||
cd "$HOME/development/projects"
|
||||
;;
|
||||
dot)
|
||||
cd "$HOME/dotfiles"
|
||||
;;
|
||||
*)
|
||||
echo "unknown target"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
[[ $TERM == "urxvt" ]] && export TERM="rxvt-unicode"
|
||||
[[ $TERM == "screen" ]] && export TERM="screen-256color"
|
||||
|
||||
### ALIASES
|
||||
|
||||
alias su="su -"
|
||||
|
||||
#LS_HIDE="*.py[co]"
|
||||
|
||||
# --dereference-command-line
|
||||
alias ls="ls --group-directories-first --classify --color=auto" #--hide=\"$LS_HIDE\""
|
||||
|
||||
alias ll='ls -AlFh'
|
||||
alias la='ls -A'
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
|
||||
alias rm='rm -v'
|
||||
alias cp='cp -v'
|
||||
alias mv='mv -v'
|
||||
alias ln='ln -v'
|
||||
|
||||
alias du='du -h'
|
||||
alias df='df -h'
|
||||
|
||||
alias root='sudo -sE'
|
||||
|
||||
alias b='cd $OLDPWD'
|
||||
|
||||
alias cs="cryptsetup"
|
||||
|
||||
alias le_haxxor_1='clear && dmesg | pv -qL $[10 + (RANDOM % 10)]'
|
||||
alias le_haxxor_2='clear && hexdump -C /dev/urandom | pv -qlL 2'
|
||||
|
||||
alias YOLO="pacman -Syu --force"
|
||||
|
||||
alias such="git"
|
||||
alias very="git"
|
||||
alias much="git"
|
||||
alias wow="git status"
|
||||
|
||||
alias v="vim"
|
||||
alias g="git"
|
||||
alias t="tmux"
|
||||
alias c="cd"
|
||||
alias l="ls"
|
||||
alias s="sudo"
|
||||
|
||||
alias tmuxa="tmux ls 2>/dev/null && tmux attach-session || tmux"
|
||||
|
||||
alias cl="clear"
|
||||
|
||||
alias calc='python3 -ic "from math import *; import cmath"'
|
||||
|
||||
# show non-printable characters by default
|
||||
alias cat="cat -v"
|
||||
|
||||
alias vimrc="vim -c ':e \$MYVIMRC'"
|
||||
alias zshrc="vim -c ':e ~/.zshrc' ; source ~/.zshrc"
|
||||
|
||||
alias vim="nvim -u $VIMRC"
|
||||
|
||||
alias psc="ps axfo pid,user,cgroup,args"
|
||||
|
||||
|
||||
# rebase the current branch onto WTF ARE YOU DOING YOU ARE DRUNNK TO GO BED
|
||||
##alias rebase="git rebase -i $(git branch --contains HEAD | grep -v '\*.*' | head -1)"
|
||||
|
||||
|
||||
### FUNCTIONS
|
||||
|
||||
_remote() {
|
||||
[[ -n "$SSH_CONNECTION" ]]
|
||||
}
|
||||
|
||||
slideshow() {
|
||||
delay=$1
|
||||
[[ -z "$delay" ]] && { echo "wrong usage" ; return 1 ; }
|
||||
shift
|
||||
[[ -z "$@" ]] && { echo "wrong usage" ; return 1 ; }
|
||||
feh --auto-zoom \
|
||||
--randomize \
|
||||
--recursive \
|
||||
--scale-down \
|
||||
--image-bg black \
|
||||
--draw-filename \
|
||||
--slideshow-delay=$delay \
|
||||
"$@"
|
||||
}
|
||||
|
||||
cd() {
|
||||
builtin cd "$@" && ls
|
||||
}
|
||||
|
||||
mount() {
|
||||
if [[ $# == 0 ]] ; then
|
||||
command mount | column -t
|
||||
else
|
||||
command mount "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
ff() {
|
||||
find . -type f -iname "*"$*"*" ;
|
||||
}
|
||||
|
||||
ffcs() {
|
||||
find . -type f -name "*"$*"*" ;
|
||||
}
|
||||
|
||||
extr()
|
||||
{
|
||||
if [[ -f "$1" ]] ; then
|
||||
case "$1" in
|
||||
*.tar.bz2 ) tar xvjf "$1" ;;
|
||||
*.tar.gz ) tar xvzf "$1" ;;
|
||||
*.tar.xz ) tar xvJf "$1" ;;
|
||||
*.bz2 ) bunzip2 "$1" ;;
|
||||
*.rar ) unrar x "$1" ;;
|
||||
*.gz ) gunzip "$1" ;;
|
||||
*.tar ) tar xvf "$1" ;;
|
||||
*.tbz2 ) tar xvjf "$1" ;;
|
||||
*.tgz ) tar xvzf "$1" ;;
|
||||
*.zip ) unzip "$1" ;;
|
||||
*.Z ) uncompress "$1" ;;
|
||||
*.7z ) 7z x "$1" ;;
|
||||
*)
|
||||
echo "$1 cannot be extracted via $0"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "$1 is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
ruler() {
|
||||
for s in '....^....|' '1234567890'; do
|
||||
w=${#s}
|
||||
str=$(for (( i=1; $i<=$(( ($COLUMNS + $w) / $w )) ; i=$i+1 )); do echo -n $s; done )
|
||||
str=$(echo $str | cut -c -$COLUMNS)
|
||||
echo $str
|
||||
done
|
||||
}
|
||||
|
||||
ssh_agent() {
|
||||
if ! _remote ; then
|
||||
if ! ssh-add -l >/dev/null ; then
|
||||
ssh-add
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
alias ssh='ssh_agent && unalias ssh; ssh'
|
||||
alias scp='ssh_agent && unalias scp; scp'
|
||||
|
||||
addext() {
|
||||
[[ -z "$1" ]] || [[ -z "$2" ]] && { echo "Usage: $0 <file> <extension>" ; return }
|
||||
mv "$1" "$1$2"
|
||||
|
||||
}
|
||||
|
||||
ckwww() {
|
||||
ping -c 3 www.google.com
|
||||
}
|
||||
|
||||
topcmds() {
|
||||
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head
|
||||
}
|
||||
|
||||
fnottype() {
|
||||
find . -maxdepth 1 ! -type $1
|
||||
}
|
||||
|
||||
httpcode() {
|
||||
curl http://httpcode.info/$1
|
||||
}
|
||||
|
||||
bak() {
|
||||
[[ -e "$1" ]] && cp -av "$1" "$1.bak"
|
||||
}
|
||||
|
||||
fstab() {
|
||||
# yeah
|
||||
expand /etc/fstab | grep -v '^#' | grep -P '^.+$' | tr -s ' ' | tr ' ' '|' | cat <(grep -P '<.+>' /etc/fstab | cut -f 2- -d ' ' | sed 's/>[^<]*</>|</g') - | column -ts '|'
|
||||
}
|
||||
|
||||
rmext() {
|
||||
[[ -e "$1" ]] && mv -i "$1" "${1%.*}"
|
||||
}
|
||||
|
||||
serve() {
|
||||
python3 -m http.server 8800
|
||||
}
|
||||
|
||||
manpdf() {
|
||||
[[ -z "$1" ]] && { printf '%s' >&2 "$(man)" ; return ; }
|
||||
man -t "$1" | ps2pdf - - | zathura -
|
||||
}
|
||||
|
||||
myip4() {
|
||||
curl "http://ipv4.icanhazip.com"
|
||||
}
|
||||
|
||||
myip6() {
|
||||
curl "http://ipv6.icanhazip.com" || echo "no ip6"
|
||||
}
|
||||
|
||||
alias myip="myip4"
|
||||
|
||||
alias clip="xclip -selection clipboard"
|
||||
alias clipo="xclip -out -selection clipboard"
|
||||
|
||||
alias tmux="tmux -2"
|
||||
|
||||
alias tm="tmux"
|
||||
alias tml="tmux list-sessions"
|
||||
alias tma="tmux attach-session"
|
||||
alias tmc="tmux switch-client -t"
|
||||
|
||||
#echo $(date +%T) >> $HOME/tmux-debug.log
|
||||
#[[ $- != *i* ]] && return
|
||||
#[[ -z "$TMUX" ]] && exec tmux -2
|
||||
|
||||
alias note="zim --plugin quicknote --notebook ~/wiki/zim/notes --page ":quicknotes" --append true"
|
||||
|
||||
alias spm="sudo pacman"s
|
||||
|
||||
alias chmod="chmod -c"
|
||||
alias chown="chown -c"
|
||||
|
||||
alias rgrep="grep -r"
|
||||
|
||||
autoload -Uz vcs_info
|
||||
zstyle ':vcs_info:*' enable git hg
|
||||
zstyle ':vcs_info:*' check-for-changes true
|
||||
zstyle ':vcs_info:git*' formats "%{${fg[cyan]}%}[%{${fg[green]}%}%s%{${fg[cyan]}%}][%{${fg[blue]}%}%r/%S%%{${fg[cyan]}%}][%{${fg[blue]}%}%b%{${fg[yellow]}%}%m%u%c%{${fg[cyan]}%}]%{$reset_color%}"
|
||||
|
||||
setprompt() {
|
||||
setopt prompt_subst
|
||||
|
||||
topstr="%{$fg[green]%}%n@%m%{$fg[white]%} ─ %{%B$fg[yellow]%}%~${vcs_info_msg_0_}%{%b%} %{$fg[white]%}"
|
||||
botstr="%B${PINFO}%#%b "
|
||||
|
||||
if _remote ; then
|
||||
topstr="%{$fg[red]%}[remote]%{$fg[white]%} ${topstr}"
|
||||
fi
|
||||
|
||||
PROMPT="%{$fg[white]%}┌─ ${topstr}
|
||||
└─ ${botstr}"
|
||||
RPROMPT="%{$fg[cyan]%}%*%{$fg[white]%} ─ [%?]"
|
||||
}
|
||||
|
||||
setprompt
|
||||
|
||||
gensshport() {
|
||||
echo $(( $(od -v -An -N4 -tu4 < /dev/urandom) % (2**16-2**10) + 2**10 ))
|
||||
}
|
||||
|
||||
#ssh() {
|
||||
# if [[ -n "$TMUX" ]] ; then
|
||||
# echo "$0 $@" > "$HOME/.var/run/tmux.$(tmux display-message -p '#S').cmd"
|
||||
# tmux detach-client >/dev/null 2>&1
|
||||
# else
|
||||
# command ssh "$@"
|
||||
# fi
|
||||
#}
|
||||
|
||||
tmux_after() {
|
||||
cmdfile="$HOME/.var/run/tmux.$1.cmd"
|
||||
if [[ -e "$cmdfile" ]] ; then
|
||||
command $(<"$cmdfile")
|
||||
rm "$cmdfile"
|
||||
if tmux has-session -t "$1" ; then
|
||||
tmux_wrap attach-session -t "$1"
|
||||
fi
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
tmux_wrap() {
|
||||
tmux "$1" "$2" "$3"
|
||||
tmux_after "$3"
|
||||
}
|
||||
|
||||
viewvm() {
|
||||
virt-viewer -rw -c qemu+ssh://root@10.1.2.4/system "${1}"
|
||||
}
|
||||
|
||||
diffdir() {
|
||||
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
|
||||
diff <(cd "$1" && find -type f | sort | xargs md5sum) <(cd "$2" && find -type f | sort | xargs md5sum)
|
||||
}
|
||||
|
||||
# desired behavior is like this:
|
||||
# if a shell is started, it automatically attaches to the lowest "s-x" session that has
|
||||
# no attached clients
|
||||
|
||||
return
|
||||
|
||||
[[ -n "$TMUX" ]] && return
|
||||
|
||||
for (( id=1 ;; id++ )) ; do
|
||||
sessionname="s-${id}"
|
||||
if tmux has-session -t "${sessionname}" ; then
|
||||
if [[ -z "$(tmux list-clients -t "${sessionname}")" ]] ; then
|
||||
tmux_wrap attach-session -t "${sessionname}"
|
||||
else
|
||||
continue
|
||||
fi
|
||||
else
|
||||
tmux_wrap new-session -s "${sessionname}"
|
||||
_files=(
|
||||
'shellopts'
|
||||
'functions'
|
||||
'variables'
|
||||
'aliases'
|
||||
'prompt')
|
||||
|
||||
for file in "${_files[@]}" ; do
|
||||
_path="$HOME"/.zsh/"$file".sh
|
||||
if [[ -e "$_path" ]] ; then
|
||||
source "$_path"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user