From 88e326062c8165cba6a99a1e0f7d7ec547a31987 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 20 Nov 2024 18:17:32 +0800 Subject: Update --- alias | 71 ++++++++++++++++++++++++++---------------------------- misc/tmux.conf | 58 ++++++++++++++++++++++++++++++++++++++++++++ profile | 16 ------------ vim/init/basic.vim | 2 +- 4 files changed, 93 insertions(+), 54 deletions(-) diff --git a/alias b/alias index aaacce6..55198cf 100644 --- a/alias +++ b/alias @@ -5,7 +5,7 @@ alias al="$EDITOR $SETTING_DIR/alias && source $SETTING_DIR/alias" # SHELL {{{ alias eof='IGNOREEOF=10' -path() { echo $PATH; } # Should not use alias, because $PATH is not initialized +path() { echo $PATH | tr : '\n' } # Should not use alias, because $PATH is not initialized eval "${shell}rc(){ local RCFILE=$XDG_CONFIG_HOME/${shell}/.${shell}rc vim \$RCFILE && source \$RCFILE @@ -18,6 +18,7 @@ ps1.swap() { unset PS1_bak fi } +alias zsh.sourced='zsh -o SOURCE_TRACE' # }}} # CUSTOM HELPER {{{ @@ -49,7 +50,8 @@ prompt-vim() { && eval $(<$TMPFILE tee /dev/tty) rm $TMPFILE } - +alias wcl='wc -l' +alias battery='cat /sys/class/power_supply/CMB0/capacity' # ls alias ll='ls -lh' @@ -74,7 +76,7 @@ date.reset() { # grep alias grep='grep --color' unalias gr &>/dev/null -gr() { grep -IR $@ . | sed '/^.\{2048\}./d'; } +gr() { grep --exclude-dir='\.git' -r $@ . | sed '/^.\{2048\}./d'; } highlight() { grep --color -E "$1|\$"; } # cron @@ -128,9 +130,10 @@ file.size() { alias s='sudo systemctl' alias j='sudo journalctl -xeu' # }}} -# TMUX {{{ +# TTY {{{ alias tma='tmux a' alias tmux.config="$EDITOR ~/.tmux.conf" +alias terminal.color='printf "\e[%dm%d dark\e[0m \e[%d;1m%d bold\e[0m\n" {30..37}{,,,}' # }}} # NETWORK {{{ @@ -147,6 +150,10 @@ ip.neigh() { ifconfig | sed -nE "/^${1}/,/^$/ s/^ +inet ([0-9.]+) .*$/\1/p" } +# }}} +# GPG {{{ +alias gpg.bye='gpg-connect-agent reloadagent /bye' +alias gpg.config="$EDITOR ~/.gnupg/gpg-agent.conf" # }}} # MAIL {{{ alias smtp.conf='sudo vim /etc/smtpd/smtpd.conf' @@ -253,7 +260,12 @@ alias xii='`fc -ln -1` | head -1 | xsel -ib' alias xo='xsel -ob' alias xl='history | tail -1 | grep -oP "^\s*[0-9]+\s\s\K.*" | xsel -ib && echo Copied to clipboard && xsel -ob' # }}} +# X11: Misc {{{ +alias x='xdg-open' +alias ob.rc='vim ~/.config/openbox/rc.xml' +# }}} # EDITOR: VIM {{{ +alias editor='select-editor' alias vimrc='vim ~/.vimrc' if which nvim &>/dev/null; then alias vim='nvim' @@ -298,7 +310,7 @@ alias cdP='cd ~/Pictures' alias cdpu='cd ~/public' alias cdV='cd ~/Videos' alias cdM='cd ~/Music' - +alias cdtrash='cd ~/.local/share/Trash' # }}} # BLOG {{{ alias cdb='cd ~/blog' @@ -362,7 +374,7 @@ upload_tig() { action=overwrite } # }}} -# GiT: GIST {{{ +# GIT: GIST {{{ alias g='gist' alias gl='gist last' unalias gg &>/dev/null @@ -394,10 +406,6 @@ github.raw() { curl -O https://raw.githubusercontent.com/$1/$2/$3 } -# }}} -# Beancount{{{ -alias cdB='cd $HOME/bean' -alias b='vim $HOME/bean/main.bean' # }}} # DEV: Docker{{{ alias dk='docker' @@ -423,10 +431,16 @@ adb.push() { adb push $1 /sdcard/Download } # }}} +# Beancount{{{ +alias cdB='cd $HOME/bean' +alias b='vim $HOME/bean/main.bean' +# }}} # python{{{ alias pip3='python3 -m pip' # }}} # sample file{{{ +alias foo='echo bar > foo && echo File foo is created && ls -lh foo' +alias bar='echo foo > bar && echo File bar is created && ls -lh bar' alias sample.text='curl http://metaphorpsum.com/paragraphs/3/5' alias sample.gpx='curl -O https://docs.mapbox.com/help/data/run.gpx' alias sample.geojson='curl -O https://docs.mapbox.com/help/data/stations.geojson' @@ -507,21 +521,6 @@ TAIWAN_BBOX='118.1036,20.72799,122.9312,26.60305' TAIWAN_BBOX_V='20.72799,118.1036,26.60305,122.9312' TAIPEI_BBOX='121.346,24.926,121.676,25.209' TAIPEI_BBOX_V='24.926,121.346,25.209,121.676' -# }}} -# Misc{{{ -alias gpg.config="$EDITOR ~/.gnupg/gpg-agent.conf" -alias foo='echo bar > foo && echo File foo is created && ls -lh foo' -alias bar='echo foo > bar && echo File bar is created && ls -lh bar' -alias wcl='wc -l' -alias x='xdg-open' -alias yl='youtube-dl' -alias yla='youtube-dl -x --audio-format mp3' -yt.audio() { - yt-dlp --verbose -x --audio-format mp3 --add-metadata $1 -} -alias editor='select-editor' -alias hp='http-prompt' -alias clocg='cloc --vcs=git' pbf() { protoc --decode_raw } @@ -535,20 +534,18 @@ mvt.decode() { mvt_decode.py $tmp | tr \' \" | sed 's/True/true/g; s/False/false/g' } wrap2geojson() { jq -s '{ type: "FeatureCollection", features: . }'; } -alias cdtrash='cd ~/.local/share/Trash' +# }}} +# Misc{{{ +alias yl='youtube-dl' +alias yla='youtube-dl -x --audio-format mp3' +yt.audio() { + yt-dlp --verbose -x --audio-format mp3 --add-metadata $1 +} +alias hp='http-prompt' +alias clocg='cloc --vcs=git' trash() { mv $@ ~/.local/share/Trash; } alias ge='graph-easy --boxart' -# }}} -# tmp{{{ -alias stew='cd ~/git/mapstew' -alias vc='vultr-cli' -alias xkb='cd $SETTING_DIR && make xkb' -alias thsr='curl -L google.com >/tmp/foo.html && xdg-open /tmp/foo.html' -todo() { cd ~/log && grep -R ' TODO ' --exclude-dir=logseq/; } -fix() { which $1 && grep -Po 'FIXME.*' $(which $1); } alias ffmpeg='ffmpeg -hide_banner' -alias md='reveal' -alias terminal.color='printf "\e[%dm%d dark\e[0m \e[%d;1m%d bold\e[0m\n" {30..37}{,,,}' -alias gpg.bye='gpg-connect-agent reloadagent /bye' alias npm='pnpm' +fix() { which $1 && grep -Po 'FIXME.*' $(which $1); } # }}} diff --git a/misc/tmux.conf b/misc/tmux.conf index bc69b14..013aee8 100644 --- a/misc/tmux.conf +++ b/misc/tmux.conf @@ -30,3 +30,61 @@ bind C-q select-layout even-horizontal bind C-w select-layout even-vertical bind C-e select-layout main-horizontal bind C-r select-layout main-vertical + +# color +# Feel free to NOT use this variables at all (remove, rename) +# this are named colors, just for convenience +color_orange="colour166" # 208, 166 +color_purple="colour134" # 135, 134 +color_green="colour076" # 070 +color_blue="colour39" +color_yellow="colour220" +color_red="colour160" +color_black="colour232" +color_white="white" # 015 + +# This is a theme CONTRACT, you are required to define variables below +# Change values, but not remove/rename variables itself +color_dark="$color_black" +color_light="$color_white" +color_session_text="$color_blue" +color_status_text="colour245" +color_main="$color_orange" +color_secondary="$color_purple" +color_level_ok="$color_green" +color_level_warn="$color_yellow" +color_level_stress="$color_red" +color_window_off_indicator="colour088" +color_window_off_status_bg="colour238" +color_window_off_status_current_bg="colour254" + +# nested tmux + +bind -T root S-F12 \ + set prefix None \;\ + set key-table off \;\ + set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\ + set window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W# #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" \;\ + set window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" \;\ + if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ + refresh-client -S \;\ + +bind -T root F12 \ + set prefix None \;\ + set key-table off \;\ + set status off \;\ + if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ + refresh-client -S \;\ + +bind -T off F12 \ + set -u prefix \;\ + set -u key-table \;\ + set -u status \;\ + set -u status-style \;\ + set -u window-status-current-style \;\ + set -u window-status-current-format \;\ + refresh-client -S + +#wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]" + +set -g status-right "$wg_is_keys_off #{sysstat_cpu} | #{sysstat_mem} | #{sysstat_loadavg} | $wg_user_host" diff --git a/profile b/profile index 12fdca0..17de89d 100644 --- a/profile +++ b/profile @@ -1,8 +1,6 @@ # trap 'exit.sh' EXIT export SETTING_DIR=${SETTING_DIR:=$HOME/helper} -export BIN_DIR=~/bin -export PATH=$BIN_DIR:$PATH export TERM=xterm-256color export XDG_CONFIG_HOME=~/.config export XDG_STATE_HOME=~/.local/share/ @@ -27,20 +25,6 @@ source $SETTING_DIR/alias [[ -d $SETTING_DIR/private ]] && for f in $SETTING_DIR/private/*; do source $f; done find $SETTING_DIR/bin -not -executable -name '*rc' | while read rcfile; do source $rcfile; done -# local -PATH=$PATH:$HOME/.local/bin -PATH=$PATH:$HOME/.local/share/gem/ruby/3.2.0/bin -# go -PATH=$PATH:$HOME/go/bin -# android-studio -PATH=$PATH:$HOME/android-studio/bin -# cargo -PATH=$PATH:$HOME/.cargo/bin -# yarn -PATH=$PATH:$HOME/.yarn/bin -# gem -PATH=$PATH:$HOME/.local/share/gem/ruby/3.0.0/bin - # fzf if which fzf &>/dev/null; then export FZF_COMPLETION_OPTS='--bind=ctrl-c:print-query' diff --git a/vim/init/basic.vim b/vim/init/basic.vim index faafc36..173df2f 100644 --- a/vim/init/basic.vim +++ b/vim/init/basic.vim @@ -154,7 +154,7 @@ set backspace=eol,start,indent " Set Backspace behaviors " TAB and special Chars {{{ -set tabstop=8 softtabstop=8 +set tabstop=4 softtabstop=4 set expandtab " Invisible chars -- cgit v1.2.3-70-g09d2