Last active
December 4, 2020 01:42
-
-
Save Phalacrocorax/9c608ac49cf295e0dfdd91f0aa90aa02 to your computer and use it in GitHub Desktop.
[template] bashrc, zshrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# bashrc_common | |
# [refer] | |
# https://gist.github.com/Phalacrocorax/9c608ac49cf295e0dfdd91f0aa90aa02 | |
# [Usage] | |
# if [ -f ~/.bashrc_common ]; then | |
# . ~/.bashrc_common | |
# fi | |
# [deploy] | |
# alias decmn="cp ~/GoogleDrive/__docs/_env/.bashrc_common ~/.bashrc_common" | |
####################### | |
## Common | |
####################### | |
# ▼ CUSTOM CONSTANT | |
# [cd] check current directory first, then check「~」 | |
CDPATH=:~ | |
# Local Hostname | |
LC_HOSTNAME=$(hostname) | |
# Local Shell Env Check | |
if [ $SHELL = '/bin/zsh' ]; then | |
LC_ENV_RC='.zshrc' | |
else | |
LC_ENV_RC='.bashrc' | |
fi | |
DOCS_ENV_PATH="~/GoogleDrive/__docs/_env" | |
# Colors | |
NC='\033[0m' | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
ORANGE='\033[0;33m' | |
BLUE='\033[0;34m' | |
PURPLE='\033[0;35m' | |
CYAN='\033[0;36m' | |
LIGHTGRAY='\033[0;37m' | |
DARKGRAY='\033[1;30m' | |
LIGHTRED='\033[1;31m' | |
LIGHTGREEN='\033[1;32m' | |
YELLOW='\033[1;33m' | |
LIGHTBLUE='\033[1;34m' | |
LIGHTPURPLE='\033[1;35m' | |
LIGHTCYAN='\033[1;36m' | |
WHITE='\033[1;37m' | |
# ▼ Terminal Display | |
# [bash] export PS1="$PURPLE\h:\w \D{%m.%d %H:%M:%S} \n\$ $NC" \h: hostname \w: path \A: HH:MM | |
# [zsh] PROMPT='' %n:username %m:hostname | |
if [ $LC_ENV_RC = '.zshrc' ]; then | |
PROMPT="%F{cyan}%m:%~ [%D{%m.%d %H:%M:%S}]%f | |
$ ${reset_color}" | |
else | |
export PS1="$PURPLE\h:\w \D{%m.%d %H:%M:%S} \n\$ $NC" | |
fi | |
# ▼ Alias | |
alias grep='grep --mmap --color' | |
alias ll='ls -al' # long list format | |
alias la='ls -A' | |
alias l='ls -CF' | |
alias op='open' | |
alias df="df -h" | |
alias ..='cd ..' | |
alias ...='cd ../../' | |
alias bkrc="cp ~/${LC_ENV_RC} $DOCS_ENV_PATH/devices/${LC_ENV_RC}_${LC_HOSTNAME}" # backup | |
alias uprc=". ~/${LC_ENV_RC} && bkrc" # update | |
alias decmn="cp ${DOCS_ENV_PATH}/.bashrc_common ~/.bashrc_common && uprc" # deploy | |
alias bashcmn="code -r $DOCS_ENV_PATH/.bashrc_common" # edit | |
alias bashrc="code -r ~/${LC_ENV_RC}" # edit | |
alias zshrc="code -r ~/${LC_ENV_RC}" # edit | |
alias sshconfig='code -r ~/.ssh/config' | |
# Git | |
alias gb='git branch' | |
alias gc='git checkout' | |
alias gs='git status' | |
alias gpl='git pull origin $(git rev-parse --abbrev-ref HEAD)' | |
alias gps='git push origin $(git rev-parse --abbrev-ref HEAD)' | |
########################## | |
###### zsh opt | |
########################## | |
if [ $LC_ENV_RC = '.zshrc' ]; then | |
# 色を使用 | |
autoload -Uz colors | |
colors | |
# 他のターミナルとヒストリーを共有 | |
setopt share_history | |
# ヒストリーに重複を表示しない | |
setopt histignorealldups | |
HISTFILE=~/.zsh_history | |
HISTSIZE=10000 | |
SAVEHIST=10000 | |
# historyに日付を表示 | |
alias h='fc -lt '%F %T' 1' | |
setopt AUTO_CD | |
fi | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KBPATH='~/GoogleDrive/__docs/_env/kb-update' | |
alias kbl="kb list" | |
alias kbe="kb edit --id" | |
alias kba="kb add" | |
alias kbv="kb view --id" | |
alias kbd="kb delete --id" | |
alias kbg="kb grep" | |
alias kbt="kb list --tags" | |
# customize | |
function kbcod(){ | |
pushd $KBPATH | |
kb export -d -f $(date '+%Y%m%d-%H%M')-$(hostname)-dataonly | |
} | |
alias kbco="pushd $KBPATH && kbcod && kb export -f export" | |
alias kbci="pushd $KBPATH && kb import export.kb.tar.gz" | |
alias kbls="ll $KBPATH" | |
alias kbvt="kb view --title" | |
alias kbet="kb edit --title" | |
alias kberc="code -r $KBPATH/.kb_alias" | |
alias kbuprc="cp $KBPATH/.kb_alias ~/.kb_alias && source ~/.kb_alias" |
nokia7.2 archlinux
PS1="\[\033[32m\](\[\033[0m\]nk7.2-arch\[\033[32m\])-(\[\033[0m\]\w\[\033[32m\])\[\033[0m\]\n\[\033[1;36m\]\u\[\033[32m\] # \[\033[0m\]"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ijt/.bashrc_common
PS1
Docker
8 Useful and Interesting Bash Prompts
https://www.maketecheasier.com/8-useful-and-interesting-bash-prompts/
PS1="\[\033[32m\][\w]\[\033[0m\]\n\[\033[1;36m\]\u\[\033[1;33m\]-> \[\033[0m\]"
PS1="\n\[\e[30;1m\]\[\016\]l\[\017\](\[\e[34;1m\]\u@\h\[\e[30;1m\])-(\[\e[34;1m\]\j\[\e[30;1m\])-(\[\e[34;1m\]\@ \d\[\e[30;1m\])->\[\e[30;1m\]\n\[\016\]m\[\017\]-(\[\[\e[32;1m\]\w\[\e[30;1m\])-(\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])--> \[\e[0m\]"
Custom