Merge pull request #3223 from mcornella/use-special-vars
Use special variables where we can
This commit is contained in:
commit
7f75bb90e3
@ -27,9 +27,9 @@ zstyle ':completion:*:*:*:*:*' menu select
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
||||
if [ "$OSTYPE[0,7]" = "solaris" ]
|
||||
then
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm"
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm"
|
||||
else
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
|
||||
fi
|
||||
|
||||
# disable named-directories autocompletion
|
||||
|
@ -3,7 +3,7 @@
|
||||
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
|
||||
#
|
||||
|
||||
dirhistory_past=(`pwd`)
|
||||
dirhistory_past=($PWD)
|
||||
dirhistory_future=()
|
||||
export dirhistory_past
|
||||
export dirhistory_future
|
||||
@ -50,7 +50,7 @@ function push_future() {
|
||||
|
||||
# Called by zsh when directory changes
|
||||
function chpwd() {
|
||||
push_past `pwd`
|
||||
push_past $PWD
|
||||
# If DIRHISTORY_CD is not set...
|
||||
if [[ -z "${DIRHISTORY_CD+x}" ]]; then
|
||||
# ... clear future.
|
||||
@ -73,7 +73,7 @@ function dirhistory_back() {
|
||||
pop_past cw
|
||||
if [[ "" == "$cw" ]]; then
|
||||
# Someone overwrote our variable. Recover it.
|
||||
dirhistory_past=(`pwd`)
|
||||
dirhistory_past=($PWD)
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -14,12 +14,12 @@ jump() {
|
||||
|
||||
mark() {
|
||||
if (( $# == 0 )); then
|
||||
MARK=$(basename "$(pwd)")
|
||||
MARK=$(basename "$PWD")
|
||||
else
|
||||
MARK="$1"
|
||||
fi
|
||||
if read -q \?"Mark $(pwd) as ${MARK}? (y/n) "; then
|
||||
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$MARK"
|
||||
if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then
|
||||
mkdir -p "$MARKPATH"; ln -s "$PWD" "$MARKPATH/$MARK"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,13 @@
|
||||
|
||||
rack_root(){
|
||||
setopt chaselinks
|
||||
local orgdir="$(pwd)"
|
||||
local basedir="$(pwd)"
|
||||
local orgdir="$PWD"
|
||||
local basedir="$PWD"
|
||||
|
||||
while [[ $basedir != '/' ]]; do
|
||||
test -e "$basedir/config.ru" && break
|
||||
builtin cd ".." 2>/dev/null
|
||||
basedir="$(pwd)"
|
||||
basedir="$PWD"
|
||||
done
|
||||
|
||||
builtin cd "$orgdir" 2>/dev/null
|
||||
@ -56,7 +56,7 @@ kapow(){
|
||||
compctl -W ~/.pow -/ kapow
|
||||
|
||||
powit(){
|
||||
local basedir="$(pwd)"
|
||||
local basedir="$PWD"
|
||||
local vhost=$1
|
||||
[ ! -n "$vhost" ] && vhost=$(rack_root_detect)
|
||||
if [ ! -h ~/.pow/$vhost ]
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# This will look for a custom profile for the local machine and each domain or
|
||||
# subdomain it belongs to. (e.g. com, example.com and foo.example.com)
|
||||
parts=(${(s:.:)$(hostname)})
|
||||
parts=(${(s:.:)$HOST})
|
||||
for i in {${#parts}..1}; do
|
||||
profile=${(j:.:)${parts[$i,${#parts}]}}
|
||||
file=$ZSH_CUSTOM/profiles/$profile
|
||||
|
@ -77,7 +77,7 @@ function svn_dirty() {
|
||||
|
||||
function svn_dirty_choose_pwd () {
|
||||
if in_svn; then
|
||||
root=`pwd`
|
||||
root=$PWD
|
||||
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then
|
||||
# Grep exits with 0 when "One or more lines were selected", return "dirty".
|
||||
echo $1
|
||||
|
@ -30,7 +30,7 @@ function retlog() {
|
||||
}
|
||||
|
||||
alias ping='ping -c 5'
|
||||
alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."'
|
||||
alias clr='clear;echo "Currently logged in on $(tty), as $USER in directory $PWD."'
|
||||
alias path='echo -e ${PATH//:/\\n}'
|
||||
alias mkdir='mkdir -pv'
|
||||
# get top process eating memory
|
||||
|
@ -9,7 +9,7 @@ function resolveFile
|
||||
if [ -f "$1" ]; then
|
||||
echo $(readlink -f "$1")
|
||||
elif [[ "${1#/}" == "$1" ]]; then
|
||||
echo "$(pwd)/$1"
|
||||
echo "$PWD/$1"
|
||||
else
|
||||
echo $1
|
||||
fi
|
||||
|
@ -89,9 +89,8 @@ function precmd {
|
||||
|
||||
# Context: user@directory or just directory
|
||||
prompt_context () {
|
||||
local user=`whoami`
|
||||
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
echo -n "${PR_RESET}${PR_RED}$user@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
echo -n "${PR_RESET}${PR_RED}$USER@%m${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
else
|
||||
echo -n "${PR_RESET}${PR_BRIGHT_YELLOW}%~%<<${PR_RESET}"
|
||||
fi
|
||||
|
@ -60,10 +60,8 @@ prompt_end() {
|
||||
|
||||
# Context: user@hostname (who am I and where am I)
|
||||
prompt_context() {
|
||||
local user=`whoami`
|
||||
|
||||
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m"
|
||||
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
|
||||
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset
|
||||
}
|
||||
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
|
||||
}
|
||||
|
||||
PROMPT='
|
||||
|
@ -21,7 +21,7 @@ local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}"
|
||||
|
||||
# Hostname part. compressed and colorcoded per host_repr array
|
||||
# if not found, regular hostname in default color
|
||||
local host="@${host_repr[$(hostname)]:-$(hostname)}%{$reset_color%}"
|
||||
local host="@${host_repr[$HOST]:-$HOST}%{$reset_color%}"
|
||||
|
||||
# Compacted $PWD
|
||||
local pwd="%{$fg[blue]%}%c%{$reset_color%}"
|
||||
|
@ -21,7 +21,7 @@ function prompt_char {
|
||||
}
|
||||
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ function prompt_char {
|
||||
}
|
||||
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || hostname -s
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || echo $SHORT_HOST || echo $HOST
|
||||
}
|
||||
|
||||
local ruby_env=''
|
||||
|
@ -1,4 +1,4 @@
|
||||
if [ "$(whoami)" = "root" ]
|
||||
if [ "$USER" = "root" ]
|
||||
then CARETCOLOR="red"
|
||||
else CARETCOLOR="blue"
|
||||
fi
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Simple theme based on my old zsh settings.
|
||||
|
||||
function get_host {
|
||||
echo '@'`hostname`''
|
||||
echo '@'$HOST
|
||||
}
|
||||
|
||||
PROMPT='> '
|
||||
|
@ -17,7 +17,7 @@ USERNAME_NORMAL_COLOR=$WHITE
|
||||
USERNAME_ROOT_COLOR=$RED
|
||||
HOSTNAME_NORMAL_COLOR=$BLUE
|
||||
# uncomment next line if you want auto-generated hostname color
|
||||
#for i in `hostname`; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]]
|
||||
#for i in $HOST; HOSTNAME_NORMAL_COLOR=$COLOR_ARRAY[$[((#i))%7+1]]
|
||||
HOSTNAME_ROOT_COLOR=$RED
|
||||
HOSTNAME_COLOR=%(!.$HOSTNAME_ROOT_COLOR.$HOSTNAME_NORMAL_COLOR)
|
||||
CURRENT_DIR_COLOR=$CYAN
|
||||
|
@ -1,4 +1,4 @@
|
||||
if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
|
||||
if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
|
||||
|
||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
if [ "$(whoami)" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
|
||||
if [ "$USER" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="magenta"; fi
|
||||
|
||||
local return_code="%(?..%{$fg_bold[red]%}:( %?%{$reset_color%})"
|
||||
|
||||
|
@ -10,7 +10,7 @@ Y=$fg_no_bold[yellow]
|
||||
B=$fg_no_bold[blue]
|
||||
RESET=$reset_color
|
||||
|
||||
if [ "$(whoami)" = "root" ]; then
|
||||
if [ "$USER" = "root" ]; then
|
||||
PROMPTCOLOR="%{$R%}" PREFIX="-!-";
|
||||
else
|
||||
PROMPTCOLOR="" PREFIX="---";
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
# Machine name.
|
||||
function box_name {
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || hostname
|
||||
[ -f ~/.box-name ] && cat ~/.box-name || echo $HOST
|
||||
}
|
||||
|
||||
# Directory info.
|
||||
@ -33,7 +33,7 @@ ${git_info} \
|
||||
%{$fg[white]%}[%*]
|
||||
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
|
||||
|
||||
if [[ "$(whoami)" == "root" ]]; then
|
||||
if [[ "$USER" == "root" ]]; then
|
||||
PROMPT="
|
||||
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
|
||||
%{$bg[yellow]%}%{$fg[cyan]%}%n%{$reset_color%} \
|
||||
|
Loading…
Reference in New Issue
Block a user