Skip to content

Instantly share code, notes, and snippets.

@wangjiezhe
Last active August 29, 2015 14:01
Show Gist options
  • Save wangjiezhe/2ae373462fad34154e66 to your computer and use it in GitHub Desktop.
Save wangjiezhe/2ae373462fad34154e66 to your computer and use it in GitHub Desktop.
~/.zshrc
# Alias
alias duh="du -d 1 -h|sort -h"
alias gsubu="git submodule update --init --recursive"
alias gfu="git fetch upstream"
alias gmuo="git merge upstream/master origin/master"
alias gmms="git merge master src"
alias glga="git log --stat --decorate --graph --all"
alias lb="ls -B"
alias cman="man -L zh_CN.utf8" # Man in Chinese
alias ack-grep="ack"
alias yiy="sudo yum install -y"
alias yuy="sudo yum upgrade -y"
alias mv="amv -g"
alias cp="acp -g"
alias bpython3="python3-bpython"
# Global alias
alias -g quiet="-q 2>/dev/null" # Used for yum
alias -g epp='-e "http_proxy=http://127.0.0.1:8087/"' # Used for wget
alias -g hpp="--http-proxy http://127.0.0.1:8087/" # Used for gem
alias -g pp="--proxy http://127.0.0.1:8087/" # User for curl
# User's function
# make a directory and open it
function mkcd {
dir="$*";
mkdir -p "$dir" && cd "$dir";
}
# Safer curl | sh'ing
function curlsh {
file=$(mktemp -t curlsh.XXXXXX) || { echo "Failed creating file"; return; }
curl -s "$1" > $file || { echo "Failed to curl file"; return; }
$EDITOR $file || { echo "Editor quit with error code"; return; }
sh $file;
rm $file;
}
# Open the next directory
cdnext() {
oldIFS=IFS
IFS=,
count=1
for file in $(ls -F ..|grep /|tr '\n' ,)
do
alldirs[count]="$file"
let count++
done
IFS=$oldIFS
currentdir=$(pwd|sed "s,^.*/\([^/]*\)$,\1/,")
for (( num=1; num<count; num++ ))
do
[ $alldirs[$num] = $currentdir ] && break
done
let num++
let count--
if [ $num -lt $count ]
then
nextdir="../$alldirs[$num]"
else
echo "All directories have been circulated. Restart from the first."
nextdir="../$alldirs[1]"
fi
cd "$nextdir"
}
# Path
PATH=$PATH:$HOME/.local/bin:$HOME/.vim/bin
export PATH
# Path for pkg-config
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig
export PKG_CONFIG_PATH
# Use fcitx rather than ibus
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
# Enable autojump
[[ -s /home/wangjiezhe/.autojump/etc/profile.d/autojump.sh ]] \
&& source /home/wangjiezhe/.autojump/etc/profile.d/autojump.sh
# Enable zsh tab completion
autoload -U compinit && compinit -u
# Always ignore case
export AUTOJUMP_IGNORE_CASE=1
# Swap Ctrl_L and CapsLock
# Enable Ctrl+Alt+Backspace to kill X
# Swap Alt_R and Escape
if [[ -n $DISPLAY ]]; then
setxkbmap -option ctrl:swapcaps
setxkbmap -option terminate:ctrl_alt_bksp
xmodmap ~/.xmodmap 2>/dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment