zsh: Overhaul, replace SHELL_CURRENT by a call to 'ps'
parent
8206b92d1c
commit
24f7bcd279
|
@ -4,8 +4,8 @@
|
|||
|
||||
## Warning: if this does not work if you change shell without relogging, use
|
||||
## 'source .<shell>rc' instead.
|
||||
|
||||
if [ "zsh" = "$SHELL_CURRENT" ]; then
|
||||
## Note that 'ps -o command= $$' gives the same result with parameters.
|
||||
if [ "zsh" = "$(ps -o comm= $$)" ]; then
|
||||
alias ssrc='source ~/.zshrc'
|
||||
fi
|
||||
|
||||
|
@ -33,6 +33,15 @@ alias lx='ls -lXh' # Sort by extension
|
|||
## Misc
|
||||
alias grep='grep --color=auto'
|
||||
|
||||
## Prevents accidentally clobbering files.
|
||||
alias mkdir='mkdir -p'
|
||||
|
||||
## Reset terminal -- Faster alternative of 'reset'.
|
||||
alias cls='printf "\ec"'
|
||||
|
||||
##==============================================================================
|
||||
## TODO: Move those to scripts?
|
||||
|
||||
# List desktop applications.
|
||||
[ -d /usr/share/applications ] && XDG_APPS=($XDG_APPS /usr/share/applications)
|
||||
[ -d /usr/local/share/applications ] && XDG_APPS=($XDG_APPS /usr/local/share/applications)
|
||||
|
@ -41,12 +50,6 @@ alias grep='grep --color=auto'
|
|||
## Get your external IP.
|
||||
command -v curl >/dev/null 2>&1 && alias myip='curl ifconfig.me'
|
||||
|
||||
## Prevents accidentally clobbering files.
|
||||
alias mkdir='mkdir -p'
|
||||
|
||||
## Reset terminal -- Faster alternative of 'reset'.
|
||||
alias cls='printf "\ec"'
|
||||
|
||||
## Start X and lock current terminal (press ENTER when back in terminal to
|
||||
## prompt for password). Useless if X is running on the same TTY.
|
||||
command -v vlock >/dev/null 2>&1 && alias sx='startx & vlock'
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
## -*- mode:sh -*- #
|
||||
|
||||
if [ "zsh" = "$SHELL_CURRENT" ]; then
|
||||
compdef _gcc crun
|
||||
compdef _gcc formatc
|
||||
compdef _gs pdfcompress
|
||||
compdef _gs pdfextract
|
||||
compdef _gs pdfresize
|
||||
compdef _pcc pacfiles
|
||||
compdef _pcc pacsize
|
||||
compdef _pcc pel
|
||||
compdef _pcc pql
|
||||
compdef _tex ltx
|
||||
compdef _path_commands typex
|
||||
compdef _pspdf zat
|
||||
fi
|
||||
## Zsh
|
||||
compdef _gcc crun
|
||||
compdef _gcc formatc
|
||||
compdef _gs pdfcompress
|
||||
compdef _gs pdfextract
|
||||
compdef _gs pdfresize
|
||||
compdef _pcc pacfiles
|
||||
compdef _pcc pacsize
|
||||
compdef _pcc pel
|
||||
compdef _pcc pql
|
||||
compdef _tex ltx
|
||||
compdef _path_commands typex
|
||||
compdef _pspdf zat
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
## -*- mode:sh -*- #
|
||||
## Shell configuration
|
||||
|
||||
## Terminal
|
||||
## WARNING: This is often a bad idea!
|
||||
## FreeBSD urxvt $TERM variable is not set properly for some reasons.
|
||||
# if [ ! "$(uname -o)" = "GNU/Linux" ]; then
|
||||
# case "$TERM" in
|
||||
# *rxvt*) export TERM="rxvt-unicode-256color";;
|
||||
# esac
|
||||
# fi
|
||||
## Most xterm-based terminals support 256 colors, so let's turn this on.
|
||||
# if [ "$TERM" = "xterm" ]; then
|
||||
# export TERM="xterm-256color"
|
||||
# fi
|
||||
## Title: If this is an xterm set the title to user@host:dir
|
||||
#case "$TERM" in
|
||||
#xterm*|rxvt*)
|
||||
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
|
||||
# ;;
|
||||
#*)
|
||||
# ;;
|
||||
#esac
|
||||
|
||||
## Enable color support of ls.
|
||||
if [ "$TERM" != "dumb" ]; then
|
||||
if [ "$OSTYPE" = "linux-gnu" ]; then
|
||||
eval "$(dircolors "$HOME/.shell.d/dircolorsdb")"
|
||||
else
|
||||
export LSCOLORS="Ex"
|
||||
# export LSCOLORS="ExfxcxDxCxdxdxCxCxECEh"
|
||||
fi
|
||||
fi
|
26
.zshrc
26
.zshrc
|
@ -1,12 +1,4 @@
|
|||
## Shell Config -- Master File
|
||||
|
||||
## Note that 'ps -o command= $$' gives the same result with parameters.
|
||||
[ -z "$SHELL_CURRENT" ] && readonly SHELL_CURRENT="$(ps -o comm= $$)"
|
||||
[ -z "$SHELL_DIR" ] && readonly SHELL_DIR="$HOME/.shell.d"
|
||||
|
||||
## .profile is sourced automatically by most login managers, but we need to
|
||||
## source it manually if in TTY.
|
||||
[ -z "$DISPLAY" ] && [ -f "$HOME/.profile" ] && . "$HOME/.profile"
|
||||
## Zsh master file
|
||||
|
||||
loadrc () {
|
||||
for i; do
|
||||
|
@ -14,17 +6,19 @@ loadrc () {
|
|||
done
|
||||
}
|
||||
|
||||
## main and options should be sourced first.
|
||||
loadrc main_rc options_zsh
|
||||
|
||||
## Source order should not matter.
|
||||
## Options should be sourced first, before the SHELL_FILEBROWSER hook.
|
||||
loadrc options_zsh
|
||||
loadrc keys_zsh
|
||||
loadrc alias_rc colors_rc completion_rc funs_rc
|
||||
|
||||
## Shell hook: should be sourced last.
|
||||
loadrc hook
|
||||
|
||||
## Assign a binding
|
||||
## sh -c 'export SHELL_FILEBROWSER=true; exec $TERMCMD'
|
||||
## and this will autostart the file browser.
|
||||
[ -n "$SHELL_FILEBROWSER" ] && unset SHELL_FILEBROWSER && browse
|
||||
|
||||
## Start at a specific location. Useful when switching to a shell from a browser
|
||||
## for instance.
|
||||
[ -n "$SHELL_CD" ] && cd "$SHELL_CD" && unsert SHELL_CD
|
||||
|
||||
## Shell hook: should be sourced last.
|
||||
loadrc hook
|
||||
|
|
Loading…
Reference in New Issue