diff --git a/.gitignore b/.gitignore index e32d9bb..02979f9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ colors/gen/tmp *.tmp *.secret /.repositories +/.env/ diff --git a/apps/htop/rc b/apps/htop/rc new file mode 100644 index 0000000..73e2ece --- /dev/null +++ b/apps/htop/rc @@ -0,0 +1,27 @@ +# Beware! This file is rewritten by htop when settings are changed in the interface. +# The parser is also very primitive, and not human-friendly. +fields=0 48 17 18 38 39 40 2 46 47 49 1 +sort_key=46 +sort_direction=1 +hide_threads=0 +hide_kernel_threads=1 +hide_userland_threads=1 +shadow_other_users=0 +show_thread_names=0 +show_program_path=0 +highlight_base_name=1 +highlight_megabytes=1 +highlight_threads=1 +tree_view=1 +header_margin=1 +detailed_cpu_time=0 +cpu_count_from_zero=0 +update_process_names=0 +account_guest_in_cpu_meter=0 +color_scheme=0 +delay=15 +left_meters=LeftCPUs2 Memory Swap +left_meter_modes=1 1 1 +right_meters=RightCPUs2 Tasks LoadAverage Uptime +right_meter_modes=1 2 2 2 +vim_mode=1 diff --git a/apps/neovim/plugins.vim b/apps/neovim/plugins.vim index d516611..55d21de 100644 --- a/apps/neovim/plugins.vim +++ b/apps/neovim/plugins.vim @@ -108,7 +108,6 @@ Plug 'sheerun/vim-polyglot' " vim plugin loa Plug 'leafo/moonscript-vim', {'for': ['moon', 'moonscript']} " moonscript language Plug 'OmniSharp/omnisharp-vim', {'for': ['cs']} " C# language Plug 'neoclide/coc.nvim', {'branch': 'release'} " language server completion -Plug 'neoclide/coc-json' " coc config ft Plug 'JakeBecker/elixir-ls', {'for': ['elixir', 'eelixir'], 'do': { -> g:elixirls.compile() }} Plug 'tpope/vim-dadbod' " databasing in vim Plug 'lytedev/elm-vim' " elm lang diff --git a/scripts/bin/N b/bin/N similarity index 100% rename from scripts/bin/N rename to bin/N diff --git a/scripts/bin/app-launcher b/bin/app-launcher similarity index 55% rename from scripts/bin/app-launcher rename to bin/app-launcher index e626c5e..a089126 100755 --- a/scripts/bin/app-launcher +++ b/bin/app-launcher @@ -2,13 +2,18 @@ source "$DOTFILES_PATH/de/bar/bar.bash" --just-vars -LAUNCHER_FONT=$(xrdb -query | sed -ne 's/.*font:\s*xft:\([^: ]*\).*$/\1/p' | head -n 1) -LAUNCHER_FONT_SIZE=$(xrdb -query | sed -ne 's/.*font:\s*xft:.*=\([0-9]*\).*$/\1/p' | head -n 1) -HIGHLIGHT_COLOR=$(xrdb -query | sed -ne 's/.*color4*:\s*\(.*\)$/\1/p' | head -n 1) -HIGHLIGHT_FOREGROUND_COLOR=$(xrdb -query | sed -ne 's/.*background:\s*\(.*\)$/\1/p' | head -n 1) -BACKGROUND_COLOR=$(xrdb -query | sed -ne 's/.*background:\s*\(.*\)$/\1/p' | head -n 1) -FOREGROUND_COLOR=$(xrdb -query | sed -ne 's/.*foreground:\s*\(.*\)$/\1/p' | head -n 1) -GAP=$(xrdb -query | sed -ne 's/.*internalBorder:\s*\(.*\)$/\1/p' | head -n 1) +LAUNCHER_FONT="$BAR_FONT" +LAUNCHER_FONT_SIZE="$BAR_FONT_SIZE" +HIGHLIGHT_COLOR="$(xrq color4)" +HIGHLIGHT_FOREGROUND_COLOR="$(xrq background)" +BACKGROUND_COLOR=$(xrq background) +FOREGROUND_COLOR=$(xrq foreground) +GAP=$(xrq internalBorder) + +# load a per-device config last so anything can be overridden +if [ -a "$EDFP/app-launcher" ]; then + source "$EDFP/app-launcher" +fi rofi \ -combi-modi run,window \ diff --git a/scripts/bin/archupdate b/bin/archupdate similarity index 100% rename from scripts/bin/archupdate rename to bin/archupdate diff --git a/scripts/bin/b b/bin/b similarity index 100% rename from scripts/bin/b rename to bin/b diff --git a/scripts/bin/bspwm_load_state b/bin/bspwm_load_state similarity index 100% rename from scripts/bin/bspwm_load_state rename to bin/bspwm_load_state diff --git a/scripts/bin/bspwm_load_state_canvas b/bin/bspwm_load_state_canvas similarity index 100% rename from scripts/bin/bspwm_load_state_canvas rename to bin/bspwm_load_state_canvas diff --git a/scripts/bin/bspwm_load_state_rules b/bin/bspwm_load_state_rules similarity index 100% rename from scripts/bin/bspwm_load_state_rules rename to bin/bspwm_load_state_rules diff --git a/scripts/bin/bspwm_save_state b/bin/bspwm_save_state similarity index 100% rename from scripts/bin/bspwm_save_state rename to bin/bspwm_save_state diff --git a/scripts/bin/calc b/bin/calc similarity index 100% rename from scripts/bin/calc rename to bin/calc diff --git a/scripts/bin/cdp b/bin/cdp similarity index 100% rename from scripts/bin/cdp rename to bin/cdp diff --git a/scripts/bin/check_domain b/bin/check_domain similarity index 100% rename from scripts/bin/check_domain rename to bin/check_domain diff --git a/scripts/bin/clipshot b/bin/clipshot similarity index 100% rename from scripts/bin/clipshot rename to bin/clipshot diff --git a/scripts/bin/countdown b/bin/countdown similarity index 100% rename from scripts/bin/countdown rename to bin/countdown diff --git a/scripts/bin/d_mosquitto b/bin/d_mosquitto similarity index 100% rename from scripts/bin/d_mosquitto rename to bin/d_mosquitto diff --git a/scripts/bin/d_rabbitmq b/bin/d_rabbitmq similarity index 100% rename from scripts/bin/d_rabbitmq rename to bin/d_rabbitmq diff --git a/scripts/bin/disable-laptop-keyboard b/bin/disable-laptop-keyboard similarity index 100% rename from scripts/bin/disable-laptop-keyboard rename to bin/disable-laptop-keyboard diff --git a/scripts/bin/editscrot b/bin/editscrot similarity index 100% rename from scripts/bin/editscrot rename to bin/editscrot diff --git a/scripts/bin/enable-laptop-keyboard b/bin/enable-laptop-keyboard similarity index 100% rename from scripts/bin/enable-laptop-keyboard rename to bin/enable-laptop-keyboard diff --git a/scripts/bin/ezln b/bin/ezln similarity index 100% rename from scripts/bin/ezln rename to bin/ezln diff --git a/bin/fsw b/bin/fsw new file mode 100755 index 0000000..73eb43d --- /dev/null +++ b/bin/fsw @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +_VERSION="0.2.0" + +function help() { + I=" " + cat < [filter] [dirs...] + +${I}command - the specified bash command to eval +${I}filter - an optional filename filter +${I}dirs - the directories to watch (defaults to current directory) + +Advanced: +${I}Command Variables: +${I}${I}Your commands have runtime access to some variables associated with the +${I}${I}${I}inotifywait event enabling further extensibility: +${I}${I}+ FSW_FILENAME - the name of the file +${I}${I}+ FSW_DIR - the directory containing the file +${I}${I}+ FSW_PATH - the full relative path of the file +${I}${I}+ FSW_FILE_EVENTS - a comma-separated list of the inotify events +${I}Environment: +${I}${I}Some customization options exist using environment variables +${I}${I}${I}due to their uncommon usage. +${I}${I}+ FSW_EVENTS - the list of events to have inotifywait observe + +References: +${I}+ Filter works with grep -P +${I}+ See inotifywait(1) for FSW_EVENTS options. + +Examples: +${I}fsw 'make' '\.c$' +${I}fsw 'bash \$filename' '\.bash$' +${I}fsw 'mix test --failed' '.exs?$' lib test +${I}FSW_EVENTS=open,access fsw 'espeak "Intruder Alert!"' \\ +${I}${I}${I}'.*' /etc/secrets \$HOME/.secrets +USAGE +} + +if [[ $1 = '-h' ]] || [[ $1 = '--help' ]] || [[ -z $1 ]]; then + help + exit 0 +fi + +FSW_EVENTS="${FSW_EVENTS:-close_write}" +SHELL_COMMAND="${1}"; shift +FILTER="${1}"; shift +DIRS=("${1:-.}"); shift +while [[ ! -z $1 ]]; do + DIRS+=("$1"); shift +done +inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \ + | grep --line-buffered -v ' Beware: since -r was given, this may take a while!' \ + | while read -r dir events filename; do + if [[ "$dir $events" = "Watches established." ]]; then + echo "Ready." + else + export FSW_FILENAME="$filename" + export FSW_DIR="$dir" + export FSW_PATH="$dir$filename" + export FSW_FILE_EVENTS="$events" + <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" + fi +done diff --git a/scripts/bin/fswi b/bin/fswi similarity index 100% rename from scripts/bin/fswi rename to bin/fswi diff --git a/scripts/bin/gcwd b/bin/gcwd similarity index 100% rename from scripts/bin/gcwd rename to bin/gcwd diff --git a/scripts/bin/git-authors b/bin/git-authors similarity index 100% rename from scripts/bin/git-authors rename to bin/git-authors diff --git a/scripts/bin/grb b/bin/grb similarity index 100% rename from scripts/bin/grb rename to bin/grb diff --git a/scripts/bin/keyrepeat b/bin/keyrepeat similarity index 100% rename from scripts/bin/keyrepeat rename to bin/keyrepeat diff --git a/scripts/bin/murxvt b/bin/murxvt similarity index 100% rename from scripts/bin/murxvt rename to bin/murxvt diff --git a/scripts/bin/n b/bin/n similarity index 100% rename from scripts/bin/n rename to bin/n diff --git a/scripts/bin/nd b/bin/nd similarity index 100% rename from scripts/bin/nd rename to bin/nd diff --git a/scripts/bin/nf b/bin/nf similarity index 100% rename from scripts/bin/nf rename to bin/nf diff --git a/scripts/bin/nsync b/bin/nsync similarity index 100% rename from scripts/bin/nsync rename to bin/nsync diff --git a/scripts/bin/pbin b/bin/pbin similarity index 100% rename from scripts/bin/pbin rename to bin/pbin diff --git a/scripts/bin/qute b/bin/qute similarity index 100% rename from scripts/bin/qute rename to bin/qute diff --git a/scripts/bin/restartbar b/bin/restartbar similarity index 100% rename from scripts/bin/restartbar rename to bin/restartbar diff --git a/scripts/bin/s b/bin/s similarity index 100% rename from scripts/bin/s rename to bin/s diff --git a/scripts/bin/scn b/bin/scn similarity index 100% rename from scripts/bin/scn rename to bin/scn diff --git a/scripts/bin/screenshot b/bin/screenshot similarity index 100% rename from scripts/bin/screenshot rename to bin/screenshot diff --git a/scripts/bin/scrup b/bin/scrup similarity index 100% rename from scripts/bin/scrup rename to bin/scrup diff --git a/scripts/bin/scwd b/bin/scwd similarity index 100% rename from scripts/bin/scwd rename to bin/scwd diff --git a/scripts/bin/setbg b/bin/setbg similarity index 100% rename from scripts/bin/setbg rename to bin/setbg diff --git a/scripts/bin/startbar b/bin/startbar similarity index 100% rename from scripts/bin/startbar rename to bin/startbar diff --git a/scripts/bin/stopbar b/bin/stopbar similarity index 100% rename from scripts/bin/stopbar rename to bin/stopbar diff --git a/scripts/bin/sw b/bin/sw similarity index 100% rename from scripts/bin/sw rename to bin/sw diff --git a/scripts/bin/term b/bin/term similarity index 100% rename from scripts/bin/term rename to bin/term diff --git a/bin/termrec b/bin/termrec new file mode 100755 index 0000000..d4a6e62 --- /dev/null +++ b/bin/termrec @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +asciinema rec -i 2 --stdin diff --git a/scripts/bin/tmux-save-buffer b/bin/tmux-save-buffer similarity index 100% rename from scripts/bin/tmux-save-buffer rename to bin/tmux-save-buffer diff --git a/scripts/bin/tmux-session-list b/bin/tmux-session-list similarity index 100% rename from scripts/bin/tmux-session-list rename to bin/tmux-session-list diff --git a/scripts/bin/tmuxswitcher b/bin/tmuxswitcher similarity index 100% rename from scripts/bin/tmuxswitcher rename to bin/tmuxswitcher diff --git a/scripts/bin/undock b/bin/undock similarity index 100% rename from scripts/bin/undock rename to bin/undock diff --git a/scripts/bin/upload b/bin/upload similarity index 100% rename from scripts/bin/upload rename to bin/upload diff --git a/scripts/bin/vman b/bin/vman similarity index 100% rename from scripts/bin/vman rename to bin/vman diff --git a/scripts/bin/wifi-list b/bin/wifi-list similarity index 100% rename from scripts/bin/wifi-list rename to bin/wifi-list diff --git a/scripts/bin/workdock b/bin/workdock similarity index 100% rename from scripts/bin/workdock rename to bin/workdock diff --git a/scripts/bin/wres1080 b/bin/wres1080 similarity index 100% rename from scripts/bin/wres1080 rename to bin/wres1080 diff --git a/scripts/bin/wsteam b/bin/wsteam similarity index 100% rename from scripts/bin/wsteam rename to bin/wsteam diff --git a/bin/xrq b/bin/xrq new file mode 100755 index 0000000..fbc3c7b --- /dev/null +++ b/bin/xrq @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [[ -z $1 ]]; then + echo "No argument provided. Showing everything..." >&2 + xrdb -query +fi + +xrdb -query | sed -ne 's/.*'"$1"':\s*\(.*\)$/\1/p' | head -n 1 diff --git a/de/bar/bar.bash b/de/bar/bar.bash index b1dd719..46c4d14 100755 --- a/de/bar/bar.bash +++ b/de/bar/bar.bash @@ -22,8 +22,9 @@ export BAR_VERTICAL_MARGIN=0 export POS_Y=0 # allow a per-device config to override options -if [ -f "$HOME/.env_bar" ]; then - source "$HOME/.env_bar" +echo "$EDFP" +if [ -f "$EDFP/bar" ]; then + source "$EDFP/bar" fi export MONITOR_WIDTH=$(xrandr | grep "^$BAR_MONITOR " | grep -Po ' \d+' | head -n 1) diff --git a/de/bspwm/config b/de/bspwm/config index f3d7db8..27a9d34 100755 --- a/de/bspwm/config +++ b/de/bspwm/config @@ -8,10 +8,11 @@ BSPWM_MONITORS=$(bspc query -M | tac) MONITOR_COUNT=$(echo "${BSPWM_MONITORS}" | wc -w | awk '{ printf $1 }') NUM_DESKTOPS=${#DESKTOPS[@]} PER_MONITOR=$((NUM_DESKTOPS / MONITOR_COUNT)) +REVERSE_DESKTOP_ORDERING=0 # allow a per-device config to override options -if [ -f "$HOME/.env_bspwm" ]; then - source "$HOME/.env_bspwm" +if [ -f "$EDFP/bspwm" ]; then + source "$EDFP/bspwm" fi bspc config normal_border_color "$(xrdb -query | sed -ne 's/.*background:\s*//p')" @@ -42,7 +43,17 @@ for mon in ${BSPWM_MONITORS}; do i=$((max + 1)) done -# allow a per-device config to override options -if [ -f "$HOME/.env_bspwm_after" ]; then - source "$HOME/.env_bspwm_after" +if [[ $REVERSE_DESKTOP_ORDERING -eq 1 ]]; then + prev_mon= + for mon in ${BSPWM_MONITORS}; do + if [[ ! -z $prev_mon ]]; then + bspc monitor "$mon" --swap "$prev_mon" + fi + prev_mon="$mon" + done +fi + +# allow a per-device config to override options +if [ -f "$EDFP/bspwm-after" ]; then + source "$EDFP/bspwm-after" fi diff --git a/de/sxhkd/sxhkdrc b/de/sxhkd/sxhkdrc index e933c38..3390cf1 100755 --- a/de/sxhkd/sxhkdrc +++ b/de/sxhkd/sxhkdrc @@ -180,7 +180,7 @@ super + shift + Return # spawn the app launcher super + space - "$DOTFILES_PATH/scripts/bin/app-launcher" -modi run -show run + app-launcher -modi run -show run # lock the desktop super + ctrl + shift + l diff --git a/de/x/loadresources b/de/x/loadresources index effc369..e9f7b1e 100755 --- a/de/x/loadresources +++ b/de/x/loadresources @@ -1,7 +1,5 @@ #!/usr/bin/env bash -echo "xloadresources" >> "$HOME/.xstartup_log" - ENV_TYPE="${1}" if [[ "$ENV_TYPE" = "auto" ]]; then @@ -10,23 +8,20 @@ if [[ "$ENV_TYPE" = "auto" ]]; then else ENV_TYPE="" fi - echo "xloadresources auto env: $ENV_TYPE" >> "$HOME/.xstartup_log" fi if [[ -z "$ENV_TYPE" ]]; then ENV_TYPE="" else - ENV_TYPE=".${ENV_TYPE}" + ENV_TYPE="${ENV_TYPE}-" fi sysresources="/etc/X11/xinit/.Xresources" sysmodmap="/etc/X11/xinit/.Xmodmap" userresources="$HOME/.Xresources" -usercolors="$HOME/.Xresources.colors" -userenv="$HOME/.Xresources${ENV_TYPE}.env" -usermodmap="$HOME/.Xmodmap" - -echo "userenv: $userenv" >> "$HOME/.xstartup_log" +usercolors="$DOTFILES_PATH/scripts/colors/xresources" +userenv="$EDFP/x/${ENV_TYPE}resources" +usermodmap="$EDFP/x/modmap" if [ -f "$sysresources" ]; then xrdb -merge "$sysresources" >/dev/null 2>&1 @@ -45,7 +40,6 @@ if [ -f "$usercolors" ]; then fi if [ -f "$userenv" ]; then - echo "Merging env Xresources: $userenv" >> ~/.xstartup_log xrdb -merge "$userenv" >/dev/null 2>&1 fi diff --git a/scripts/bin/fsw b/scripts/bin/fsw deleted file mode 100755 index 7bd9f8b..0000000 --- a/scripts/bin/fsw +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -SHELL_COMMAND="${1}" -shift -inotifywait -q -m -e close_write -r "${@}" | while read -r _ _; do - eval "${SHELL_COMMAND}" -done diff --git a/scripts/env_bin/.gitignore b/scripts/env_bin/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/scripts/env_bin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/setup b/setup index 27fde63..52c4326 100755 --- a/setup +++ b/setup @@ -1,6 +1,10 @@ #!/usr/bin/env bash -# TODO: ascii art header +# TODO: ascii art header since I'm a leet haxx0r + +dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd) +source "${dfp}/scripts/setup_helpers.bash" +edfp="${dfp}/.env" INTERACTIVE=1 @@ -13,9 +17,6 @@ while test $# -gt 0; do esac done -dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd) -source "${dfp}/scripts/setup_helpers.bash" - links=( # desktop environment files "$dfp/de/bspwm/bspwmrc" "$XDG_CONFIG_HOME/bspwm/bspwmrc" @@ -66,6 +67,9 @@ links=( # document viewer "$dfp/apps/zathura/" "$XDG_CONFIG_HOME/zathura" + # htop + "$dfp/apps/htop/rc" "$XDG_CONFIG_HOME/htop/htoprc" + # terminal emulator "$dfp/apps/alacritty/" "$XDG_CONFIG_HOME/alacritty" @@ -98,6 +102,33 @@ links=( "$dfp/shell/user-dirs" "$XDG_CONFIG_HOME/user-dirs.dirs" ) +mkdir -p "$edfp/" +if [[ ! -L "$HOME/.env" ]]; then + ln -s "$edfp/" "$HOME/.env/" +fi +mkdir -p "$edfp/bash.d/" +mkdir -p "$edfp/bin/" +mkdir -p "$edfp/x/" +mkdir -p "$HOME/.bin/" + +touches=( + "$edfp/bash" + "$edfp/x/init" + "$edfp/x/profile" + "$edfp/x/resources" + "$edfp/vim" + "$edfp/bspwm" + "$edfp/bar" + "$edfp/app-launcher" +) + +for t in "${touches[@]}"; do + touch "$t" +done + +chmod 700 -R "$edfp" +chmod 700 -R "$HOME/.bin" + # TODO: pass interactive? _dotfiles_setup_run_setup "$dfp/.agreed-to-erasing-files.lock" "${links[@]}" diff --git a/shell/bash/bashrc b/shell/bash/bashrc index 6987810..62cc1ab 100644 --- a/shell/bash/bashrc +++ b/shell/bash/bashrc @@ -5,6 +5,8 @@ # for making sure they're loaded! export XDG_CONFIG_HOME="$HOME/.config" export DOTFILES_PATH="$XDG_CONFIG_HOME/dotfiles" +export ENV_DOTFILES_PATH="$DOTFILES_PATH/.env" +export EDFP="$ENV_DOTFILES_PATH" # shorter alias NICE_HOME="$HOME" # TODO: better logic for auto-detecting alternative home directories? @@ -98,8 +100,8 @@ HISTIGNORE='ls:ll:la' shopt -s cmdhist # load a per-device config last so anything can be overridden -if [ -a "$HOME/.env_bashrc" ]; then - source "$HOME/.env_bashrc" +if [ -a "$EDFP/bash" ]; then + source "$EDFP/bash" fi # we assume the user uses "$HOME" to just store their mess of dotfiles and other diff --git a/shell/bash/paths b/shell/bash/paths index 379babd..db31b9a 100644 --- a/shell/bash/paths +++ b/shell/bash/paths @@ -4,9 +4,9 @@ export GOPATH="$HOME/.go" # PATH=$PATH:$APPENDED_PATH export PATH=$PATH:"$GOPATH/bin" -export PATH=$PATH:"$DOTFILES_PATH/scripts/bin" -export PATH=$PATH:"$DOTFILES_PATH/scripts/env_bin" -export PATH=$PATH:"$HOME/.env_bin" +export PATH=$PATH:"$DOTFILES_PATH/bin" +export PATH=$PATH:"$EDFP/bin" +export PATH=$PATH:"$HOME/.bin" export PATH=$PATH:"$HOME/.cargo/bin" export PATH=$PATH:"$HOME/.yarn/bin" diff --git a/shell/bash/prompt b/shell/bash/prompt index 6123afe..3290750 100644 --- a/shell/bash/prompt +++ b/shell/bash/prompt @@ -1,43 +1,36 @@ #!/usr/bin/env bash COLOR_RESET='\[\e[0m\]' +# TODO: if root, background instead? PROMPT_SUCCESS_COLOR='\[\e[0;34m\]' PROMPT_FAILURE_COLOR='\[\e[0;31m\]' DIR_COLOR='\[\e[0;35m\]' +MAX_PATH_PIECE_CHARS=${BASH_PROMPT_MAX_PATH_PIECE_CHARS:-3} + # prompt rendering functions preprocess_pwd() { - name="$PWD" - # if we're in the home directory, replace it with tilde - # [[ "$name" =~ ^"$NICE_HOME"(/|$) ]] && name="~${name#$NICE_HOME}" - [[ "$name" == "${NICE_HOME}" ]] && name="~" - - # replace all non-basename parts of the PWD with only the first two letters - curdir=$(echo "$PWD" | sed -r 's|.*/(.+)$|\1|g') - name=$(echo "$name" | sed -r 's|/(...)[^/]*|/\1|g' | sed -r 's|(.*/)(.+)$|\1|g') - - # if we're just in the home or root directory, don't show any path stuff - [[ "$name" == "/" ]] && curdir="" - [[ "$name" == "~" ]] && curdir="" - - # return our transformed PWD - echo "$name$curdir" + p="$PWD" + [[ "$p" == "/" ]] && echo "/" && return 1 + [[ "$p" == "${NICE_HOME}" ]] && echo "~" && return 0 + # with ellipsis + #echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){if(k==length(p)){printf "/%s",p[k]}else{if(length(p[k])>'"$((MAX_PATH_PIECE_CHARS+1))"'){printf "/%.'"$((MAX_PATH_PIECE_CHARS))"'s…",p[k]}else{printf "/%s",p[k]}}}}')" + # without ellipsis + echo "$(<<< "$p" cut -c2- | awk '{split($0,p,"/");for(k in p){if(k==length(p)){printf "/%s",p[k]}else{printf "/%.'"$MAX_PATH_PIECE_CHARS"'s",p[k]}}}')" } export -f "preprocess_pwd" prompt_command_func() { - # commit history to prevent data loss from edge cases - history -a RET=$? - # set the color of the user and host based on the result of the previous - # command - if [ $RET -eq 0 ]; then + history -a # commit history to prevent data loss from edge cases + # set the color of user@host based on the result of the previous command + if [[ $RET -eq 0 ]]; then STATUS_COLOR=$PROMPT_SUCCESS_COLOR else STATUS_COLOR=$PROMPT_FAILURE_COLOR - fi; - PS1="$STATUS_COLOR\u@\h$COLOR_RESET $DIR_COLOR$(eval "preprocess_pwd")$COLOR_RESET " + fi + PS1="$STATUS_COLOR\u@\h$COLOR_RESET $DIR_COLOR$(preprocess_pwd)$COLOR_RESET " } export -f "prompt_command_func" export PROMPT_COMMAND="prompt_command_func" diff --git a/shell/tmux/tmux.conf b/shell/tmux/tmux.conf index 4e6958b..8f6fb33 100644 --- a/shell/tmux/tmux.conf +++ b/shell/tmux/tmux.conf @@ -43,7 +43,7 @@ bind-key j switch-client -p bind-key h switch-client -p bind-key k switch-client -n bind-key l switch-client -n -bind s run "tmux new-window 'sh -ci tmuxswitcher'" +bind s run-shell "tmux new-window 'sh -c ~/.config/dotfiles/bin/tmuxswitcher'" # reset the working directory of the current session bind-key P attach-session -t . -c '#{pane_current_path}' \; display-message 'Reset session dir to #{pane_current_path}' @@ -57,9 +57,9 @@ set -g status-interval 5 set -g status-right-length 80 set -g status-right "#[fg=colour4]#W#[fg=default]#[bg=default] #H" set -g status-left-length 200 -set -g status-left "#[fg=colour7]#(~/.config/dotfiles/scripts/bin/tmux-session-list #S)" +set -g status-left "#[fg=colour7]#(~/.config/dotfiles/bin/tmux-session-list #S)" -bind-key O run-shell "~/.config/dotfiles/scripts/bin/tmux-save-buffer #S" \; display-message "Saved buffer to ~/.tmux-buffer.log" +bind-key O run-shell "~/.config/dotfiles/bin/tmux-save-buffer #S" \; display-message "Saved buffer to ~/.tmux-buffer.log" # pane split line colors set -g pane-active-border-style bg=black,fg=black