commit e15ad6aa303b3c91be8b98eb4f480ecb59e9d482 Author: Marc Sastre Rienitz Date: Sun May 17 20:00:08 2020 +0200 Initial commit with fish, i3, nvim and polybar configuration diff --git a/.config/fish/aliases.fish b/.config/fish/aliases.fish new file mode 100644 index 0000000..c0bb32d --- /dev/null +++ b/.config/fish/aliases.fish @@ -0,0 +1,38 @@ +# vim +alias vim="nvim" +alias vi="nvim" + +# dotfiles +alias dotfiles='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' + +# git aliases +alias gs='git status' +alias gd='git diff' +alias gdom='git diff origin/master' +alias gdomns='git diff origin/master --name-status' +alias ga='git add' +alias gall='git add --all' +alias gc='git commit' +alias gcm='git commit -m' +alias gcam='git commit -am' +alias gco='git checkout' +alias gcob='git checkout -b' +alias gm='git merge' +alias gmom='git merge origin/master' +alias gstash='git stash' +alias gsl='git stash list' +alias gsp='git stash pop' +alias gg='git lgb' +alias gpull='git pull' +alias gpush='git push' + +# Postgres connections +alias local_psql='psql -d vilynx-db -U vilynx-web' +alias test_psql='psql -h postgres2.test.east.vilynx.com -d vilynx-db -U vilynx-web -p 5432' +alias prod_psql='ssh -f vilynxro@apache71.prod.east.vilynx.com -L 5440:localhost:5433 sleep 600; psql -h localhost -p 5440 -d vilynx-db -U vilynx-web' + +# Redshift connection +alias test_redshift='psql -h redshift.test.east.vilynx.com -d dagda_insights -p 5439 -U dagda_user' +alias prod_redshift='psql -h redshift.east.vilynx.com -d dagda_insights -p 5439 -U dagda_user' + +alias kraken_psql='psql -h kraken.vpn.vilynx.com -d vilynx-db -U vilynx-web -p 5432' diff --git a/.config/fish/completions/fisher.fish b/.config/fish/completions/fisher.fish new file mode 100644 index 0000000..271e314 --- /dev/null +++ b/.config/fish/completions/fisher.fish @@ -0,0 +1 @@ +fisher complete diff --git a/.config/fish/conf.d/fisher.fish b/.config/fish/conf.d/fisher.fish new file mode 100644 index 0000000..63f65b0 --- /dev/null +++ b/.config/fish/conf.d/fisher.fish @@ -0,0 +1 @@ +# fisher copy-user-key-bindings diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..7a12ee3 --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,64 @@ +set fish_greeting "" + +######################### +# ALIASES # +######################### +alias ll='ls -alhF' +alias la='ls -A' +alias l='ls -CF' +. ~/.config/fish/aliases.fish + +######################### +# FUNCTIONS # +######################### +# Manage AWS credentials +function aws-credentials + if test -d ~/.aws + rm ~/.aws; + end + ln -s .aws.$argv .aws +end + +# Activate venv +function venv + if type -q deactivate + deactivate; + end + . ~/venv/$argv/bin/activate.fish +end + +# Go to vilynx repo folder and activate venv +function repo + if test -d ~/vilynx/repos/$argv + cd ~/vilynx/repos/$argv; + venv $argv + else + echo "Could'nt find repo $argv" + end +end + +# Clear postgresql cache +function clear_psql_cache + sudo service postgresql stop + echo 3 | sudo tee /proc/sys/vm/drop_caches + sudo service postgresql start +end + +# Install "minimal" python packages +function setup-python + pip install autopep8 flake8 isort ipython pdbpp pip-tools pynvim +end + +######################### +# THEME # +######################### +set -g theme_color_scheme zenburn + +######################### +# MISC # +######################### +set -x VIRTUAL_ENV_DISABLE_PROMPT 1 + +set -x PGHOST localhost +set -x PYENV_ROOT "$HOME/.pyenv" +set -x PATH "$PYENV_ROOT/bin" $PATH diff --git a/.config/fish/fishd.msastre-vilynx b/.config/fish/fishd.msastre-vilynx new file mode 100644 index 0000000..fb248cd --- /dev/null +++ b/.config/fish/fishd.msastre-vilynx @@ -0,0 +1,39 @@ +# This file is automatically generated by the fish. +# Do NOT edit it directly, your changes will be overwritten. +SET FZF_DEFAULT_OPTS:\x2d\x2dheight\x2040\x25 +SET FZF_LEGACY_KEYBINDINGS:1 +SET FZF_PREVIEW_DIR_CMD:ls +SET FZF_PREVIEW_FILE_CMD:head\x20\x2dn\x2010 +SET FZF_TMUX_HEIGHT:40\x25 +SET __fish_classic_git_prompt_initialized:\x1d +SET __fish_init_2_39_8:\x1d +SET __fish_init_2_3_0:\x1d +SET fish_color_autosuggestion:555\x1ebrblack +SET fish_color_cancel:\x2dr +SET fish_color_command:\x2d\x2dbold +SET fish_color_comment:red +SET fish_color_cwd:green +SET fish_color_cwd_root:red +SET fish_color_end:brmagenta +SET fish_color_error:brred +SET fish_color_escape:bryellow\x1e\x2d\x2dbold +SET fish_color_history_current:\x2d\x2dbold +SET fish_color_host:normal +SET fish_color_match:\x2d\x2dbackground\x3dbrblue +SET fish_color_normal:normal +SET fish_color_operator:bryellow +SET fish_color_param:cyan +SET fish_color_quote:yellow +SET fish_color_redirection:brblue +SET fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SET fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SET fish_color_status:red +SET fish_color_user:brgreen +SET fish_color_valid_path:\x2d\x2dunderline +SET fish_greeting: +SET fish_key_bindings:fish_vi_key_bindings +SET fish_pager_color_completion:\x1d +SET fish_pager_color_description:B3A06D\x1eyellow +SET fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SET fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SET fish_user_paths:/home/marc/\x2efzf/bin diff --git a/.config/fish/fishfile b/.config/fish/fishfile new file mode 100644 index 0000000..0795310 --- /dev/null +++ b/.config/fish/fishfile @@ -0,0 +1,2 @@ +jorgebucaran/fish-bax +oh-my-fish/theme-bobthefish diff --git a/.config/fish/functions/__bobthefish_colors.fish b/.config/fish/functions/__bobthefish_colors.fish new file mode 100644 index 0000000..8b25309 --- /dev/null +++ b/.config/fish/functions/__bobthefish_colors.fish @@ -0,0 +1,636 @@ +function __bobthefish_colors -S -a color_scheme -d 'Define colors used by bobthefish' + switch "$color_scheme" + case 'user' + __bobthefish_user_color_scheme_deprecated + return + + case 'terminal' 'terminal-dark*' + set -l colorfg black + [ "$color_scheme" = 'terminal-dark-white' ]; and set colorfg white + set -x color_initial_segment_exit white red --bold + set -x color_initial_segment_su white green --bold + set -x color_initial_segment_jobs white blue --bold + + set -x color_path black white + set -x color_path_basename black white --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree black $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username white black --bold + set -x color_hostname white black + set -x color_rvm brmagenta $colorfg --bold + set -x color_nvm brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'terminal-light*' + set -l colorfg white + [ "$color_scheme" = 'terminal-light-black' ]; and set colorfg black + set -x color_initial_segment_exit black red --bold + set -x color_initial_segment_su black green --bold + set -x color_initial_segment_jobs black blue --bold + + set -x color_path white black + set -x color_path_basename white black --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree white $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username black white --bold + set -x color_hostname black white + set -x color_rvm brmagenta $colorfg --bold + set -x color_nvm brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'terminal2' 'terminal2-dark*' + set -l colorfg black + [ "$color_scheme" = 'terminal2-dark-white' ]; and set colorfg white + set -x color_initial_segment_exit grey red --bold + set -x color_initial_segment_su grey green --bold + set -x color_initial_segment_jobs grey blue --bold + + set -x color_path brgrey white + set -x color_path_basename brgrey white --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree brgrey $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username brgrey white --bold + set -x color_hostname brgrey white + set -x color_rvm brmagenta $colorfg --bold + set -x color_nvm brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'terminal2-light*' + set -l colorfg white + [ "$color_scheme" = 'terminal2-light-black' ]; and set colorfg black + set -x color_initial_segment_exit brgrey red --bold + set -x color_initial_segment_su brgrey green --bold + set -x color_initial_segment_jobs brgrey blue --bold + + set -x color_path grey black + set -x color_path_basename grey black --bold + set -x color_path_nowrite magenta $colorfg + set -x color_path_nowrite_basename magenta $colorfg --bold + + set -x color_repo green $colorfg + set -x color_repo_work_tree grey $colorfg --bold + set -x color_repo_dirty brred $colorfg + set -x color_repo_staged yellow $colorfg + + set -x color_vi_mode_default brblue $colorfg --bold + set -x color_vi_mode_insert brgreen $colorfg --bold + set -x color_vi_mode_visual bryellow $colorfg --bold + + set -x color_vagrant brcyan $colorfg + set -x color_k8s magenta white --bold + set -x color_username grey black --bold + set -x color_hostname grey black + set -x color_rvm brmagenta $colorfg --bold + set -x color_nvm brgreen $colorfg --bold + set -x color_virtualfish brblue $colorfg --bold + set -x color_virtualgo brblue $colorfg --bold + set -x color_desk brblue $colorfg --bold + + case 'zenburn' + set -l grey 333333 # a bit darker than normal zenburn grey + set -l red CC9393 + set -l green 7F9F7F + set -l yellow E3CEAB + set -l orange DFAF8F + set -l blue 8CD0D3 + set -l white DCDCCC + + set -x color_initial_segment_exit $white $red --bold + set -x color_initial_segment_su $white $green --bold + set -x color_initial_segment_jobs $white $blue --bold + + set -x color_path $grey $white + set -x color_path_basename $grey $white --bold + set -x color_path_nowrite $grey $red + set -x color_path_nowrite_basename $grey $red --bold + + set -x color_repo $green $grey + set -x color_repo_work_tree $grey $grey --bold + set -x color_repo_dirty $red $grey + set -x color_repo_staged $yellow $grey + + set -x color_vi_mode_default $grey $yellow --bold + set -x color_vi_mode_insert $green $white --bold + set -x color_vi_mode_visual $yellow $grey --bold + + set -x color_vagrant $blue $green --bold + set -x color_k8s $green $white --bold + set -x color_username $grey $blue --bold + set -x color_hostname $grey $blue + set -x color_rvm $red $grey --bold + set -x color_nvm $green $white --bold + set -x color_virtualfish $blue $grey --bold + set -x color_virtualgo $blue $grey --bold + set -x color_desk $blue $grey --bold + + case 'base16-light' + set -l base00 181818 + set -l base01 282828 + set -l base02 383838 + set -l base03 585858 + set -l base04 b8b8b8 + set -l base05 d8d8d8 + set -l base06 e8e8e8 + set -l base07 f8f8f8 + set -l base08 ab4642 # red + set -l base09 dc9656 # orange + set -l base0A f7ca88 # yellow + set -l base0B a1b56c # green + set -l base0C 86c1b9 # cyan + set -l base0D 7cafc2 # blue + set -l base0E ba8baf # violet + set -l base0F a16946 # brown + + set -l colorfg $base00 + + set -x color_initial_segment_exit $base02 $base08 --bold + set -x color_initial_segment_su $base02 $base0B --bold + set -x color_initial_segment_jobs $base02 $base0D --bold + + set -x color_path $base06 $base02 + set -x color_path_basename $base06 $base01 --bold + set -x color_path_nowrite $base06 $base08 + set -x color_path_nowrite_basename $base06 $base08 --bold + + set -x color_repo $base0B $colorfg + set -x color_repo_work_tree $base06 $colorfg --bold + set -x color_repo_dirty $base08 $colorfg + set -x color_repo_staged $base09 $colorfg + + set -x color_vi_mode_default $base04 $colorfg --bold + set -x color_vi_mode_insert $base0B $colorfg --bold + set -x color_vi_mode_visual $base09 $colorfg --bold + + set -x color_vagrant $base0C $colorfg --bold + set -x color_k8s $base06 $colorfg --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_rvm $base08 $colorfg --bold + set -x color_nvm $base0B $colorfg --bold + set -x color_virtualfish $base0D $colorfg --bold + set -x color_virtualgo $base0D $colorfg --bold + set -x color_desk $base0D $colorfg --bold + + case 'base16' 'base16-dark' + set -l base00 181818 + set -l base01 282828 + set -l base02 383838 + set -l base03 585858 + set -l base04 b8b8b8 + set -l base05 d8d8d8 + set -l base06 e8e8e8 + set -l base07 f8f8f8 + set -l base08 ab4642 # red + set -l base09 dc9656 # orange + set -l base0A f7ca88 # yellow + set -l base0B a1b56c # green + set -l base0C 86c1b9 # cyan + set -l base0D 7cafc2 # blue + set -l base0E ba8baf # violet + set -l base0F a16946 # brown + + set -l colorfg $base07 + + set -x color_initial_segment_exit $base05 $base08 --bold + set -x color_initial_segment_su $base05 $base0B --bold + set -x color_initial_segment_jobs $base05 $base0D --bold + + set -x color_path $base02 $base05 + set -x color_path_basename $base02 $base06 --bold + set -x color_path_nowrite $base02 $base08 + set -x color_path_nowrite_basename $base02 $base08 --bold + + set -x color_repo $base0B $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $base08 $colorfg + set -x color_repo_staged $base09 $colorfg + + set -x color_vi_mode_default $base03 $colorfg --bold + set -x color_vi_mode_insert $base0B $colorfg --bold + set -x color_vi_mode_visual $base09 $colorfg --bold + + set -x color_vagrant $base0C $colorfg --bold + set -x color_k8s $base0B $colorfg --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_rvm $base08 $colorfg --bold + set -x color_nvm $base0B $colorfg --bold + set -x color_virtualfish $base0D $colorfg --bold + set -x color_virtualgo $base0D $colorfg --bold + set -x color_desk $base0D $colorfg --bold + + case 'solarized-light' + set -l base03 002b36 + set -l base02 073642 + set -l base01 586e75 + set -l base00 657b83 + set -l base0 839496 + set -l base1 93a1a1 + set -l base2 eee8d5 + set -l base3 fdf6e3 + set -l yellow b58900 + set -l orange cb4b16 + set -l red dc322f + set -l magenta d33682 + set -l violet 6c71c4 + set -l blue 268bd2 + set -l cyan 2aa198 + set -l green 859900 + + set colorfg $base03 + + set -x color_initial_segment_exit $base02 $red --bold + set -x color_initial_segment_su $base02 $green --bold + set -x color_initial_segment_jobs $base02 $blue --bold + + set -x color_path $base2 $base00 + set -x color_path_basename $base2 $base01 --bold + set -x color_path_nowrite $base2 $orange + set -x color_path_nowrite_basename $base2 $orange --bold + + set -x color_repo $green $colorfg + set -x color_repo_work_tree $base2 $colorfg --bold + set -x color_repo_dirty $red $colorfg + set -x color_repo_staged $yellow $colorfg + + set -x color_vi_mode_default $blue $colorfg --bold + set -x color_vi_mode_insert $green $colorfg --bold + set -x color_vi_mode_visual $yellow $colorfg --bold + + set -x color_vagrant $violet $colorfg --bold + set -x color_k8s $green $colorfg --bold + set -x color_username $base2 $blue --bold + set -x color_hostname $base2 $blue + set -x color_rvm $red $colorfg --bold + set -x color_nvm $green $colorfg --bold + set -x color_virtualfish $cyan $colorfg --bold + set -x color_virtualgo $cyan $colorfg --bold + set -x color_desk $cyan $colorfg --bold + + case 'solarized' 'solarized-dark' + set -l base03 002b36 + set -l base02 073642 + set -l base01 586e75 + set -l base00 657b83 + set -l base0 839496 + set -l base1 93a1a1 + set -l base2 eee8d5 + set -l base3 fdf6e3 + set -l yellow b58900 + set -l orange cb4b16 + set -l red dc322f + set -l magenta d33682 + set -l violet 6c71c4 + set -l blue 268bd2 + set -l cyan 2aa198 + set -l green 859900 + + set colorfg $base3 + + set -x color_initial_segment_exit $base2 $red --bold + set -x color_initial_segment_su $base2 $green --bold + set -x color_initial_segment_jobs $base2 $blue --bold + + set -x color_path $base02 $base0 + set -x color_path_basename $base02 $base1 --bold + set -x color_path_nowrite $base02 $orange + set -x color_path_nowrite_basename $base02 $orange --bold + + set -x color_repo $green $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $red $colorfg + set -x color_repo_staged $yellow $colorfg + + set -x color_vi_mode_default $blue $colorfg --bold + set -x color_vi_mode_insert $green $colorfg --bold + set -x color_vi_mode_visual $yellow $colorfg --bold + + set -x color_vagrant $violet $colorfg --bold + set -x color_k8s $green $colorfg --bold + set -x color_username $base02 $blue --bold + set -x color_hostname $base02 $blue + set -x color_rvm $red $colorfg --bold + set -x color_nvm $green $colorfg --bold + set -x color_virtualfish $cyan $colorfg --bold + set -x color_virtualgo $cyan $colorfg --bold + set -x color_desk $cyan $colorfg --bold + + case 'light' + # light medium dark + # ------ ------ ------ + set -l red cc9999 ce000f 660000 + set -l green addc10 189303 0c4801 + set -l blue 48b4fb 005faf 255e87 + set -l orange f6b117 unused 3a2a03 + set -l brown bf5e00 803f00 4d2600 + set -l grey cccccc 999999 333333 + set -l white ffffff + set -l black 000000 + set -l ruby_red af0000 + + set -x color_initial_segment_exit $grey[3] $red[2] --bold + set -x color_initial_segment_su $grey[3] $green[2] --bold + set -x color_initial_segment_jobs $grey[3] $blue[3] --bold + + set -x color_path $grey[1] $grey[2] + set -x color_path_basename $grey[1] $grey[3] --bold + set -x color_path_nowrite $red[1] $red[3] + set -x color_path_nowrite_basename $red[1] $red[3] --bold + + set -x color_repo $green[1] $green[3] + set -x color_repo_work_tree $grey[1] $white --bold + set -x color_repo_dirty $red[2] $white + set -x color_repo_staged $orange[1] $orange[3] + + set -x color_vi_mode_default $grey[2] $grey[3] --bold + set -x color_vi_mode_insert $green[2] $grey[3] --bold + set -x color_vi_mode_visual $orange[1] $orange[3] --bold + + set -x color_vagrant $blue[1] $white --bold + set -x color_k8s $green[1] $colorfg --bold + set -x color_username $grey[1] $blue[3] --bold + set -x color_hostname $grey[1] $blue[3] + set -x color_rvm $ruby_red $grey[1] --bold + set -x color_nvm $green $grey[1] --bold + set -x color_virtualfish $blue[2] $grey[1] --bold + set -x color_virtualgo $blue[2] $grey[1] --bold + set -x color_desk $blue[2] $grey[1] --bold + + case 'gruvbox' + # light medium dark darkest + # ------ ------ ------ ------- + set -l red fb4934 cc241d + set -l green b8bb26 98971a + set -l yellow fabd2f d79921 + set -l aqua 8ec07c 689d6a + set -l blue 83a598 458588 + set -l grey cccccc 999999 333333 + set -l fg fbf1c7 ebdbb2 d5c4a1 a89984 + set -l bg 504945 282828 + + set -x color_initial_segment_exit $fg[1] $red[2] --bold + set -x color_initial_segment_su $fg[1] $green[2] --bold + set -x color_initial_segment_jobs $fg[1] $aqua[2] --bold + + set -x color_path $bg[1] $fg[2] + set -x color_path_basename $bg[1] $fg[2] --bold + set -x color_path_nowrite $red[1] $fg[2] + set -x color_path_nowrite_basename $red[1] $fg[2] --bold + + set -x color_repo $green[2] $bg[1] + set -x color_repo_work_tree $bg[1] $fg[2] --bold + set -x color_repo_dirty $red[2] $fg[2] + set -x color_repo_staged $yellow[1] $bg[1] + + set -x color_vi_mode_default $fg[4] $bg[2] --bold + set -x color_vi_mode_insert $blue[1] $bg[2] --bold + set -x color_vi_mode_visual $yellow[1] $bg[2] --bold + + set -x color_vagrant $blue[2] $fg[2] --bold + set -x color_k8s $green[2] $fg[2] --bold + set -x color_username $fg[3] $blue[2] --bold + set -x color_hostname $fg[3] $blue[2] + set -x color_rvm $red[2] $fg[2] --bold + set -x color_nvm $green[1] $fg[2] --bold + set -x color_virtualfish $blue[2] $fg[2] --bold + set -x color_virtualgo $blue[2] $fg[2] --bold + set -x color_desk $blue[2] $fg[2] --bold + + case 'dracula' # https://draculatheme.com + set -l bg 282a36 + set -l current_line 44475a + set -l selection 44475a + set -l fg f8f8f2 + set -l comment 6272a4 + set -l cyan 8be9fd + set -l green 50fa7b + set -l orange ffb86c + set -l pink ff79c6 + set -l purple bd93f9 + set -l red ff5555 + set -l yellow f1fa8c + + set -x color_initial_segment_exit $fg $red --bold + set -x color_initial_segment_su $fg $purple --bold + set -x color_initial_segment_jobs $fg $comment --bold + + set -x color_path $selection $fg + set -x color_path_basename $selection $fg --bold + set -x color_path_nowrite $selection $red + set -x color_path_nowrite_basename $selection $red --bold + + set -x color_repo $green $bg + set -x color_repo_work_tree $selection $fg --bold + set -x color_repo_dirty $red $bg + set -x color_repo_staged $yellow $bg + + set -x color_vi_mode_default $bg $yellow --bold + set -x color_vi_mode_insert $green $bg --bold + set -x color_vi_mode_visual $orange $bg --bold + + set -x color_vagrant $pink $bg --bold + set -x color_k8s $green $fg --bold + set -x color_username $selection $cyan --bold + set -x color_hostname $selection $cyan + set -x color_rvm $red $bg --bold + set -x color_nvm $green $bg --bold + set -x color_virtualfish $comment $bg --bold + set -x color_virtualgo $cyan $bg --bold + set -x color_desk $comment $bg --bold + + case 'nord' + set -l base00 2E3440 + set -l base01 3B4252 + set -l base02 434C5E + set -l base03 4C566A + set -l base04 D8DEE9 + set -l base05 E5E9F0 + set -l base06 ECEFF4 + set -l base07 8FBCBB + set -l base08 88C0D0 + set -l base09 81A1C1 + set -l base0A 5E81AC + set -l base0B BF616A + set -l base0C D08770 + set -l base0D EBCB8B + set -l base0E A3BE8C + set -l base0F B48EAD + + set -l colorfg $base00 + + set -x color_initial_segment_exit $base05 $base08 --bold + set -x color_initial_segment_su $base05 $base0B --bold + set -x color_initial_segment_jobs $base08 $base0D --bold + + set -x color_path $base02 $base05 + set -x color_path_basename $base02 $base06 --bold + set -x color_path_nowrite $base02 $base08 + set -x color_path_nowrite_basename $base02 $base08 --bold + + set -x color_repo $base0E $colorfg + set -x color_repo_work_tree $base02 $colorfg --bold + set -x color_repo_dirty $base0B $colorfg + set -x color_repo_staged $base0D $colorfg + + set -x color_vi_mode_default $base08 $colorfg --bold + set -x color_vi_mode_insert $base06 $colorfg --bold + set -x color_vi_mode_visual $base07 $colorfg --bold + + set -x color_vagrant $base02 $colorfg --bold + set -x color_k8s $base02 $colorfg --bold + set -x color_username $base02 $base0D --bold + set -x color_hostname $base02 $base0D + set -x color_rvm $base09 $colorfg --bold + set -x color_nvm $base09 $colorfg --bold + set -x color_virtualfish $base09 $colorfg --bold + set -x color_virtualgo $base09 $colorfg --bold + set -x color_desk $base09 $colorfg --bold + + case '*' # default dark theme + # light medium dark + # ------ ------ ------ + set -l red cc9999 ce000f 660000 + set -l green addc10 189303 0c4801 + set -l blue 48b4fb 005faf 255e87 + set -l orange f6b117 unused 3a2a03 + set -l brown bf5e00 803f00 4d2600 + set -l grey cccccc 999999 333333 + set -l white ffffff + set -l black 000000 + set -l ruby_red af0000 + set -l go_blue 00d7d7 + + set -x color_initial_segment_exit $white $red[2] --bold + set -x color_initial_segment_su $white $green[2] --bold + set -x color_initial_segment_jobs $white $blue[3] --bold + + set -x color_path $grey[3] $grey[2] + set -x color_path_basename $grey[3] $white --bold + set -x color_path_nowrite $red[3] $red[1] + set -x color_path_nowrite_basename $red[3] $red[1] --bold + + set -x color_repo $green[1] $green[3] + set -x color_repo_work_tree $grey[3] $white --bold + set -x color_repo_dirty $red[2] $white + set -x color_repo_staged $orange[1] $orange[3] + + set -x color_vi_mode_default $grey[2] $grey[3] --bold + set -x color_vi_mode_insert $green[2] $grey[3] --bold + set -x color_vi_mode_visual $orange[1] $orange[3] --bold + + set -x color_vagrant $blue[1] $white --bold + set -x color_k8s $green[2] $white --bold + set -x color_username $grey[1] $blue[3] --bold + set -x color_hostname $grey[1] $blue[3] + set -x color_rvm $ruby_red $grey[1] --bold + set -x color_nvm $green[1] $white --bold + set -x color_virtualfish $blue[2] $grey[1] --bold + set -x color_virtualgo $go_blue $black --bold + set -x color_desk $blue[2] $grey[1] --bold + end +end + +function __bobthefish_user_color_scheme_deprecated + set -q __color_initial_segment_exit; or set -l __color_initial_segment_exit ffffff ce000f --bold + set -q __color_initial_segment_su; or set -l __color_initial_segment_su ffffff 189303 --bold + set -q __color_initial_segment_jobs; or set -l __color_initial_segment_jobs ffffff 255e87 --bold + set -q __color_path; or set -l __color_path 333333 999999 + set -q __color_path_basename; or set -l __color_path_basename 333333 ffffff --bold + set -q __color_path_nowrite; or set -l __color_path_nowrite 660000 cc9999 + set -q __color_path_nowrite_basename; or set -l __color_path_nowrite_basename 660000 cc9999 --bold + set -q __color_repo; or set -l __color_repo addc10 0c4801 + set -q __color_repo_work_tree; or set -l __color_repo_work_tree 333333 ffffff --bold + set -q __color_repo_dirty; or set -l __color_repo_dirty ce000f ffffff + set -q __color_repo_staged; or set -l __color_repo_staged f6b117 3a2a03 + set -q __color_vi_mode_default; or set -l __color_vi_mode_default 999999 333333 --bold + set -q __color_vi_mode_insert; or set -l __color_vi_mode_insert 189303 333333 --bold + set -q __color_vi_mode_visual; or set -l __color_vi_mode_visual f6b117 3a2a03 --bold + set -q __color_vagrant; or set -l __color_vagrant 48b4fb ffffff --bold + set -q __color_username; or set -l __color_username cccccc 255e87 --bold + set -q __color_hostname; or set -l __color_hostname cccccc 255e87 + set -q __color_rvm; or set -l __color_rvm af0000 cccccc --bold + set -q __color_virtualfish; or set -l __color_virtualfish 005faf cccccc --bold + set -q __color_virtualgo; or set -l __color_virtualgo 005faf cccccc --bold + set -q __color_desk; or set -l __color_desk 005faf cccccc --bold + + set_color black -b red --bold + echo "The 'user' color scheme is deprecated." + set_color normal + set_color black -b red + echo "To define a custom color scheme, create a 'bobthefish_colors' function:" + set_color normal + echo + + echo "function bobthefish_colors -S -d 'Define a custom bobthefish color scheme' + + # optionally include a base color scheme... + ___bobthefish_colors default + + # then override everything you want! note that these must be defined with `set -x` + set -x color_initial_segment_exit $__color_initial_segment_exit + set -x color_initial_segment_su $__color_initial_segment_su + set -x color_initial_segment_jobs $__color_initial_segment_jobs + set -x color_path $__color_path + set -x color_path_basename $__color_path_basename + set -x color_path_nowrite $__color_path_nowrite + set -x color_path_nowrite_basename $__color_path_nowrite_basename + set -x color_repo $__color_repo + set -x color_repo_work_tree $__color_repo_work_tree + set -x color_repo_dirty $__color_repo_dirty + set -x color_repo_staged $__color_repo_staged + set -x color_vi_mode_default $__color_vi_mode_default + set -x color_vi_mode_insert $__color_vi_mode_insert + set -x color_vi_mode_visual $__color_vi_mode_visual + set -x color_vagrant $__color_vagrant + set -x color_username $__color_username + set -x color_hostname $__color_hostname + set -x color_rvm $__color_rvm + set -x color_virtualfish $__color_virtualfish + set -x color_virtualgo $__color_virtualgo + set -x color_desk $__color_desk +end" + + echo +end diff --git a/.config/fish/functions/__bobthefish_display_colors.fish b/.config/fish/functions/__bobthefish_display_colors.fish new file mode 100644 index 0000000..210a803 --- /dev/null +++ b/.config/fish/functions/__bobthefish_display_colors.fish @@ -0,0 +1,3 @@ +function __bobthefish_display_colors -d 'Print example prompts using the current color scheme' + bobthefish_display_colors +end diff --git a/.config/fish/functions/__bobthefish_glyphs.fish b/.config/fish/functions/__bobthefish_glyphs.fish new file mode 100644 index 0000000..aedfa0e --- /dev/null +++ b/.config/fish/functions/__bobthefish_glyphs.fish @@ -0,0 +1,93 @@ +function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish' + # Powerline glyphs + set -x branch_glyph \uE0A0 + set -x right_black_arrow_glyph \uE0B0 + set -x right_arrow_glyph \uE0B1 + set -x left_black_arrow_glyph \uE0B2 + set -x left_arrow_glyph \uE0B3 + + # Additional glyphs + set -x detached_glyph \u27A6 + set -x tag_glyph \u2302 + set -x nonzero_exit_glyph '! ' + set -x superuser_glyph '$ ' + set -x bg_job_glyph '% ' + set -x hg_glyph \u263F + + # Python glyphs + set -x superscript_glyph \u00B9 \u00B2 \u00B3 + set -x virtualenv_glyph 'py' # \u25F0 + set -x pypy_glyph \u1D56 + + set -x ruby_glyph '' + set -x go_glyph '' + + # Desk glyphs + set -x desk_glyph \u25F2 + + # Kubernetes glyphs + set -x k8s_glyph \u2388 # '⎈' + + # Vagrant glyphs + set -x vagrant_running_glyph \u2191 # ↑ 'running' + set -x vagrant_poweroff_glyph \u2193 # ↓ 'poweroff' + set -x vagrant_aborted_glyph \u2715 # ✕ 'aborted' + set -x vagrant_saved_glyph \u21E1 # ⇡ 'saved' + set -x vagrant_stopping_glyph \u21E3 # ⇣ 'stopping' + set -x vagrant_unknown_glyph '!' # strange cases + + # Git glyphs + set -x git_dirty_glyph '*' + set -x git_staged_glyph '~' + set -x git_stashed_glyph '$' + set -x git_untracked_glyph '…' + set -x git_ahead_glyph \u2191 # '↑' + set -x git_behind_glyph \u2193 # '↓' + set -x git_plus_glyph '+' + set -x git_minus_glyph '-' + set -x git_plus_minus_glyph '±' + + # Disable Powerline fonts (unless we're using nerd fonts instead) + if [ "$theme_powerline_fonts" = "no" -a "$theme_nerd_fonts" != "yes" ] + set branch_glyph \u2387 + set right_black_arrow_glyph '' + set right_arrow_glyph '' + set left_black_arrow_glyph '' + set left_arrow_glyph '' + end + + # Use prettier Nerd Fonts glyphs + if [ "$theme_nerd_fonts" = "yes" ] + set branch_glyph \uF418 + set detached_glyph \uF417 + set tag_glyph \uF412 + + set virtualenv_glyph \uE73C ' ' + set ruby_glyph \uE791 ' ' + set go_glyph \uE626 ' ' + set node_glyph \uE718 ' ' + + set vagrant_running_glyph \uF431 # ↑ 'running' + set vagrant_poweroff_glyph \uF433 # ↓ 'poweroff' + set vagrant_aborted_glyph \uF468 # ✕ 'aborted' + set vagrant_unknown_glyph \uF421 # strange cases + + set git_dirty_glyph \uF448 '' # nf-oct-pencil + set git_staged_glyph \uF0C7 '' # nf-fa-save + set git_stashed_glyph \uF0C6 '' # nf-fa-paperclip + set git_untracked_glyph \uF128 '' # nf-fa-question + # set git_untracked_glyph \uF141 '' # nf-fa-ellipsis_h + + set git_ahead_glyph \uF47B # nf-oct-chevron_up + set git_behind_glyph \uF47C # nf-oct-chevron_down + + set git_plus_glyph \uF0DE # fa-sort-asc + set git_minus_glyph \uF0DD # fa-sort-desc + set git_plus_minus_glyph \uF0DC # fa-sort + end + + # Avoid ambiguous glyphs + if [ "$theme_avoid_ambiguous_glyphs" = "yes" ] + set git_untracked_glyph '...' + end +end diff --git a/.config/fish/functions/bax.fish b/.config/fish/functions/bax.fish new file mode 100644 index 0000000..72af5b2 --- /dev/null +++ b/.config/fish/functions/bax.fish @@ -0,0 +1,46 @@ +set -g bax_version 1.0.0 + +complete -xc bax -n __fish_use_subcommand -a --help -d "Show usage help" +complete -xc bax -n __fish_use_subcommand -a --version -d "$bax_version" + +function bax + switch "$argv" + case {,-}-h{elp,} "" + echo "usage: bax Run a bash command" + echo " bax --help Show this help" + echo " bax --version Show the current version" + case {,-}-v{ersion,} + echo "bax version $bax_version" + case \* + set -l delim "@@@@bax@@@@" + command bash -c " + $argv + status=\$? + [ \$status -eq 0 ] && echo $delim && alias && echo $delim && command awk ' + BEGIN { + for (k in ENVIRON) + if (gsub(/\n/, \"\\\n\", ENVIRON[k]) >= 0) + print k, ENVIRON[k] + } + ' || echo $delim \$status + " | command awk -v delim="$delim" ' + $0 != delim || !++i { + if ($1 == delim) exit $2 + else if (i < 2) print (i ? $0 : gsub(/\$/, "\\\$") >= 0 ? "echo \"" $0 "\"" : "") + else env[$1] = (gsub(/\\\n/, "\n") >= 0 ? substr($0, length($1) + 2) : "") + } + END { + for (k in env) + if (len++ && k !~ /^(_|SHLVL|PS1|XPC_SERVICE_NAME|AWK(LIB)?PATH)$|^BASH_FUNC/\ + && !(k in ENVIRON && ENVIRON[k] == env[k])) + print (\ + k == "PATH" && gsub(/:/, "\" \"", env[k]) >= 0\ + ? "set PATH \"" env[k] "\"" : k == "PWD"\ + ? "cd \"" env[k] "\"" : "set -gx " k " \"" env[k] "\""\ + ) + if (!len) print "exit " $2 + else for (k in ENVIRON) if (!(k in env)) print "set -e " k + } + ' | source + end +end diff --git a/.config/fish/functions/bobthefish_display_colors.fish b/.config/fish/functions/bobthefish_display_colors.fish new file mode 100644 index 0000000..2abb5ab --- /dev/null +++ b/.config/fish/functions/bobthefish_display_colors.fish @@ -0,0 +1,135 @@ +function bobthefish_display_colors -a color_scheme -d 'Print example prompt color schemes' + + set -l color_schemes default light \ + solarized solarized-light \ + base16 base16-light \ + gruvbox zenburn \ + dracula \ + terminal terminal-dark-white \ + terminal-light terminal-light-black \ + terminal2 terminal2-dark-white \ + terminal2-light terminal2-light-black + + switch "$color_scheme" + case '--all' + for scheme in $color_schemes + echo + echo "$scheme:" + bobthefish_display_colors $scheme + end + return + + case $color_schemes + __bobthefish_colors $color_scheme + + case '' + [ -n "$theme_color_scheme" ] + and echo "$theme_color_scheme:" + __bobthefish_colors $theme_color_scheme + type -q bobthefish_colors + and bobthefish_colors + + case '*' + echo 'usage: bobthefish_display_colors [--all] [color_scheme]' + return + end + + __bobthefish_glyphs + + echo + set_color normal + + __bobthefish_start_segment $color_initial_segment_exit + echo -n exit $nonzero_exit_glyph + set_color -b $color_initial_segment_su + echo -n su $superuser_glyph + set_color -b $color_initial_segment_jobs + echo -n jobs $bg_job_glyph + __bobthefish_finish_segments + set_color normal + echo -n "(<- initial_segment)" + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path_nowrite + echo -n /color/path/nowrite/ + set_color -b $color_path_nowrite_basename + echo -ns basename ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_start_segment $color_repo + echo -n "$branch_glyph repo $git_stashed_glyph " + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_start_segment $color_repo_dirty + echo -n "$tag_glyph repo_dirty $git_dirty_glyph " + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_path + echo -n /color/path/ + set_color -b $color_path_basename + echo -ns basename ' ' + __bobthefish_start_segment $color_repo_staged + echo -n "$detached_glyph repo_staged $git_staged_glyph " + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_vi_mode_default + echo -ns vi_mode_default ' ' + __bobthefish_finish_segments + __bobthefish_start_segment $color_vi_mode_insert + echo -ns vi_mode_insert ' ' + __bobthefish_finish_segments + __bobthefish_start_segment $color_vi_mode_visual + echo -ns vi_mode_visual ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_running_glyph ' ' vagrant ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_username + echo -n username + set_color normal + set_color -b $color_hostname[1] $color_hostname[2..-1] + echo -ns @hostname ' ' + __bobthefish_finish_segments + echo + + __bobthefish_start_segment $color_rvm + echo -ns $ruby_glyph rvm ' ' + __bobthefish_finish_segments + + __bobthefish_start_segment $color_virtualfish + echo -ns $virtualenv_glyph virtualfish ' ' + __bobthefish_finish_segments + + __bobthefish_start_segment $color_virtualgo + echo -ns $go_glyph virtualgo ' ' + __bobthefish_finish_segments + + __bobthefish_start_segment $color_desk + echo -ns $desk_glyph desk ' ' + __bobthefish_finish_segments + + echo -e "\n" +end diff --git a/.config/fish/functions/fish_greeting.fish b/.config/fish/functions/fish_greeting.fish new file mode 100644 index 0000000..dbd8616 --- /dev/null +++ b/.config/fish/functions/fish_greeting.fish @@ -0,0 +1,10 @@ +function fish_greeting -d "What's up, fish?" + set_color $fish_color_autosuggestion + uname -nmsr + + # TODO: `command -q -s` only works on fish 2.5+, so hold off on that for now + command -s uptime >/dev/null + and command uptime + + set_color normal +end diff --git a/.config/fish/functions/fish_mode_prompt.fish b/.config/fish/functions/fish_mode_prompt.fish new file mode 100644 index 0000000..304b705 --- /dev/null +++ b/.config/fish/functions/fish_mode_prompt.fish @@ -0,0 +1,9 @@ +# This is handled inside fish_mode_prompt (see `__bobthefish_prompt_vi`) +# +# If you want to override this with your own mode prompt, disable bobthefish's +# built-in mode prompt in your fish config: +# +# set -g theme_display_vi no + +function fish_mode_prompt +end diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..5a86afd --- /dev/null +++ b/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,1107 @@ +# name: bobthefish +# +# bobthefish is a Powerline-style, Git-aware fish theme optimized for awesome. +# +# You will need a Powerline-patched font for this to work: +# +# https://powerline.readthedocs.org/en/master/installation.html#patched-fonts +# +# I recommend picking one of these: +# +# https://github.com/Lokaltog/powerline-fonts +# +# For more advanced awesome, install a nerd fonts patched font (and be sure to +# enable nerd fonts support with `set -g theme_nerd_fonts yes`): +# +# https://github.com/ryanoasis/nerd-fonts +# +# You can override some default prompt options in your config.fish: +# +# set -g theme_display_git no +# set -g theme_display_git_dirty no +# set -g theme_display_git_untracked no +# set -g theme_display_git_ahead_verbose yes +# set -g theme_display_git_dirty_verbose yes +# set -g theme_display_git_stashed_verbose yes +# set -g theme_display_git_master_branch yes +# set -g theme_git_worktree_support yes +# set -g theme_display_vagrant yes +# set -g theme_display_docker_machine no +# set -g theme_display_k8s_context yes +# set -g theme_display_k8s_namespace no +# set -g theme_display_hg yes +# set -g theme_display_virtualenv no +# set -g theme_display_ruby no +# set -g theme_display_user ssh +# set -g theme_display_hostname ssh +# set -g theme_display_sudo_user yes +# set -g theme_display_vi no +# set -g theme_display_nvm yes +# set -g theme_avoid_ambiguous_glyphs yes +# set -g theme_powerline_fonts no +# set -g theme_nerd_fonts yes +# set -g theme_show_exit_status yes +# set -g theme_display_jobs_verbose yes +# set -g default_user your_normal_user +# set -g theme_color_scheme dark +# set -g fish_prompt_pwd_dir_length 0 +# set -g theme_project_dir_length 1 +# set -g theme_newline_cursor yes + + +# ============================== +# Helper methods +# ============================== + +function __bobthefish_basename -d 'basically basename, but faster' + string replace -r '^.*/' '' -- $argv +end + +function __bobthefish_dirname -d 'basically dirname, but faster' + string replace -r '/[^/]+/?$' '' -- $argv +end + +function __bobthefish_pwd -d 'Get a normalized $PWD' + # The pwd builtin accepts `-P` on at least Fish 3.x, but fall back to $PWD if that doesn't work + builtin pwd -P 2>/dev/null + or echo $PWD +end + +function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)' + set -l ref (command git symbolic-ref HEAD 2>/dev/null) + and begin + [ "$theme_display_git_master_branch" != 'yes' -a "$ref" = 'refs/heads/master' ] + and echo $branch_glyph + and return + + # truncate the middle of the branch name, but only if it's 25+ characters + set -l truncname $ref + [ "$theme_use_abbreviated_branch_name" = 'yes' ] + and set truncname (string replace -r '^(.{28}).{3,}(.{5})$' "\$1…\$2" $ref) + + string replace -r '^refs/heads/' "$branch_glyph " $truncname + and return + end + + set -l tag (command git describe --tags --exact-match 2>/dev/null) + and echo "$tag_glyph $tag" + and return + + set -l branch (command git show-ref --head -s --abbrev | head -n1 2>/dev/null) + echo "$detached_glyph $branch" +end + +function __bobthefish_hg_branch -S -d 'Get the current hg branch' + set -l branch (command hg branch 2>/dev/null) + set -l book (command hg book | command grep \* | cut -d\ -f3) + echo "$branch_glyph $branch @ $book" +end + +function __bobthefish_pretty_parent -S -a child_dir -d 'Print a parent directory, shortened to fit the prompt' + set -q fish_prompt_pwd_dir_length + or set -l fish_prompt_pwd_dir_length 1 + + # Replace $HOME with ~ + set -l real_home ~ + set -l parent_dir (string replace -r '^'"$real_home"'($|/)' '~$1' (__bobthefish_dirname $child_dir)) + + # Must check whether `$parent_dir = /` if using native dirname + if [ -z "$parent_dir" ] + echo -n / + return + end + + if [ $fish_prompt_pwd_dir_length -eq 0 ] + echo -n "$parent_dir/" + return + end + + string replace -ar '(\.?[^/]{'"$fish_prompt_pwd_dir_length"'})[^/]*/' '$1/' "$parent_dir/" +end + +function __bobthefish_ignore_vcs_dir -a real_pwd -d 'Check whether the current directory should be ignored as a VCS segment' + for p in $theme_vcs_ignore_paths + set ignore_path (realpath $p 2>/dev/null) + switch $real_pwd/ + case $ignore_path/\* + echo 1 + return + end + end +end + +function __bobthefish_git_project_dir -S -a real_pwd -d 'Print the current git project base directory' + [ "$theme_display_git" = 'no' ] + and return + + set -q theme_vcs_ignore_paths + and [ (__bobthefish_ignore_vcs_dir $real_pwd) ] + and return + + if [ "$theme_git_worktree_support" != 'yes' ] + set -l git_toplevel (command git rev-parse --show-toplevel 2>/dev/null) + + [ -z "$git_toplevel" ] + and return + + # If there are no symlinks, just use git toplevel + switch $real_pwd/ + case $git_toplevel/\* + echo $git_toplevel + return + end + + # Otherwise, we need to find the equivalent directory in the $PWD + set -l d $real_pwd + while not [ -z "$d" ] + if [ (realpath "$d") = "$git_toplevel" ] + echo $d + return + end + + [ "$d" = '/' ] + and return + + set d (__bobthefish_dirname $d) + end + return + end + + set -l git_dir (command git rev-parse --git-dir 2>/dev/null) + or return + + pushd $git_dir + set git_dir $real_pwd + popd + + switch $real_pwd/ + case $git_dir/\* + # Nothing works quite right if we're inside the git dir + # TODO: fix the underlying issues then re-enable the stuff below + + # # if we're inside the git dir, sweet. just return that. + # set -l toplevel (command git rev-parse --show-toplevel 2>/dev/null) + # if [ "$toplevel" ] + # switch $git_dir/ + # case $toplevel/\* + # echo $git_dir + # end + # end + return + end + + set -l project_dir (__bobthefish_dirname $git_dir) + + switch $real_pwd/ + case $project_dir/\* + echo $project_dir + return + end + + set project_dir (command git rev-parse --show-toplevel 2>/dev/null) + switch $real_pwd/ + case $project_dir/\* + echo $project_dir + end +end + +function __bobthefish_hg_project_dir -S -a real_pwd -d 'Print the current hg project base directory' + [ "$theme_display_hg" = 'yes' ] + or return + + set -q theme_vcs_ignore_paths + and [ (__bobthefish_ignore_vcs_dir $real_pwd) ] + and return + + set -l d $real_pwd + while not [ -z "$d" ] + if [ -e $d/.hg ] + command hg root --cwd "$d" 2>/dev/null + return + end + + [ "$d" = '/' ] + and return + + set d (__bobthefish_dirname $d) + end +end + +function __bobthefish_project_pwd -S -a project_root_dir -a real_pwd -d 'Print the working directory relative to project root' + set -q theme_project_dir_length + or set -l theme_project_dir_length 0 + + set -l project_dir (string replace -r '^'"$project_root_dir"'($|/)' '' $real_pwd) + + if [ $theme_project_dir_length -eq 0 ] + echo -n $project_dir + return + end + + string replace -ar '(\.?[^/]{'"$theme_project_dir_length"'})[^/]*/' '$1/' $project_dir +end + +function __bobthefish_git_ahead -S -d 'Print the ahead/behind state for the current branch' + if [ "$theme_display_git_ahead_verbose" = 'yes' ] + __bobthefish_git_ahead_verbose + return + end + + set -l ahead 0 + set -l behind 0 + for line in (command git rev-list --left-right '@{upstream}...HEAD' 2>/dev/null) + switch "$line" + case '>*' + if [ $behind -eq 1 ] + echo '±' + return + end + set ahead 1 + case '<*' + if [ $ahead -eq 1 ] + echo "$git_plus_minus_glyph" + return + end + set behind 1 + end + end + + if [ $ahead -eq 1 ] + echo "$git_plus_glyph" + else if [ $behind -eq 1 ] + echo "$git_minus_glyph" + end +end + +function __bobthefish_git_ahead_verbose -S -d 'Print a more verbose ahead/behind state for the current branch' + set -l commits (command git rev-list --left-right '@{upstream}...HEAD' 2>/dev/null) + or return + + set -l behind (count (for arg in $commits; echo $arg; end | command grep '^<')) + set -l ahead (count (for arg in $commits; echo $arg; end | command grep -v '^<')) + + switch "$ahead $behind" + case '' # no upstream + case '0 0' # equal to upstream + return + case '* 0' # ahead of upstream + echo "$git_ahead_glyph$ahead" + case '0 *' # behind upstream + echo "$git_behind_glyph$behind" + case '*' # diverged from upstream + echo "$git_ahead_glyph$ahead$git_behind_glyph$behind" + end +end + +function __bobthefish_git_dirty_verbose -S -d 'Print a more verbose dirty state for the current working tree' + set -l changes (command git diff --numstat | awk '{ added += $1; removed += $2 } END { print "+" added "/-" removed }') + or return + + echo "$changes " | string replace -r '(\+0/(-0)?|/-0)' '' +end + +function __bobthefish_git_stashed -S -d 'Print the stashed state for the current branch' + if [ "$theme_display_git_stashed_verbose" = 'yes' ] + set -l stashed (command git rev-list --walk-reflogs --count refs/stash 2>/dev/null) + or return + + echo -n "$git_stashed_glyph$stashed" + else + command git rev-parse --verify --quiet refs/stash >/dev/null + and echo -n "$git_stashed_glyph" + end +end + + +# ============================== +# Segment functions +# ============================== + +function __bobthefish_start_segment -S -d 'Start a prompt segment' + set -l bg $argv[1] + set -e argv[1] + set -l fg $argv[1] + set -e argv[1] + + set_color normal # clear out anything bold or underline... + set_color -b $bg $fg $argv + + switch "$__bobthefish_current_bg" + case '' + # If there's no background, just start one + echo -n ' ' + case "$bg" + # If the background is already the same color, draw a separator + echo -ns $right_arrow_glyph ' ' + case '*' + # otherwise, draw the end of the previous segment and the start of the next + set_color $__bobthefish_current_bg + echo -ns $right_black_arrow_glyph ' ' + set_color $fg $argv + end + + set __bobthefish_current_bg $bg +end + +function __bobthefish_path_segment -S -a segment_dir -d 'Display a shortened form of a directory' + set -l segment_color $color_path + set -l segment_basename_color $color_path_basename + + if not [ -w "$segment_dir" ] + set segment_color $color_path_nowrite + set segment_basename_color $color_path_nowrite_basename + end + + __bobthefish_start_segment $segment_color + + set -l directory + set -l parent + + switch "$segment_dir" + case / + set directory '/' + case "$HOME" + set directory '~' + case '*' + set parent (__bobthefish_pretty_parent "$segment_dir") + set directory (__bobthefish_basename "$segment_dir") + end + + echo -n $parent + set_color -b $segment_basename_color + echo -ns $directory ' ' +end + +function __bobthefish_finish_segments -S -d 'Close open prompt segments' + if [ -n "$__bobthefish_current_bg" ] + set_color normal + set_color $__bobthefish_current_bg + echo -ns $right_black_arrow_glyph ' ' + end + + if [ "$theme_newline_cursor" = 'yes' ] + echo -ens "\n" + set_color $fish_color_autosuggestion + + if set -q theme_newline_prompt + echo -ens "$theme_newline_prompt" + else if [ "$theme_powerline_fonts" = "no" ] + echo -ns '> ' + else + echo -ns "$right_arrow_glyph " + end + else if [ "$theme_newline_cursor" = 'clean' ] + echo -ens "\n" + end + + set_color normal + set __bobthefish_current_bg +end + + +# ============================== +# Status and input mode segments +# ============================== + +function __bobthefish_prompt_status -S -a last_status -d 'Display flags for a non-zero exit status, root user, and background jobs' + set -l nonzero + set -l superuser + set -l bg_jobs + + # Last exit was nonzero + [ $last_status -ne 0 ] + and set nonzero 1 + + # If superuser (uid == 0) + # + # Note that iff the current user is root and '/' is not writeable by root this + # will be wrong. But I can't think of a single reason that would happen, and + # it is literally 99.5% faster to check it this way, so that's a tradeoff I'm + # willing to make. + [ -w / -o -w /private/ ] + and [ (id -u) -eq 0 ] + and set superuser 1 + + # Jobs display + if set -q AUTOJUMP_SOURCED + # Autojump special case: check if there are jobs besides the `autojump` + # job, since that one is (briefly) backgrounded every time we `cd` + set bg_jobs (jobs -c | string match -v --regex '(Command|autojump)' | wc -l) + [ "$bg_jobs" -eq 0 ] + and set bg_jobs # clear it out so it doesn't show when `0` + else + if [ "$theme_display_jobs_verbose" = 'yes' ] + set bg_jobs (jobs -p | wc -l) + [ "$bg_jobs" -eq 0 ] + and set bg_jobs # clear it out so it doesn't show when `0` + else + # `jobs -p` is faster if we redirect to /dev/null, because it exits + # after the first match. We'll use that unless the user wants to + # display the actual job count + jobs -p >/dev/null + and set bg_jobs 1 + end + end + + if [ "$nonzero" -o "$superuser" -o "$bg_jobs" ] + __bobthefish_start_segment $color_initial_segment_exit + if [ "$nonzero" ] + set_color normal + set_color -b $color_initial_segment_exit + if [ "$theme_show_exit_status" = 'yes' ] + echo -ns $last_status ' ' + else + echo -n $nonzero_exit_glyph + end + end + + if [ "$superuser" ] + set_color normal + if [ -z "$FAKEROOTKEY" ] + set_color -b $color_initial_segment_su + else + set_color -b $color_initial_segment_exit + end + + echo -n $superuser_glyph + end + + if [ "$bg_jobs" ] + set_color normal + set_color -b $color_initial_segment_jobs + if [ "$theme_display_jobs_verbose" = 'yes' ] + echo -ns $bg_job_glyph $bg_jobs ' ' + else + echo -n $bg_job_glyph + end + end + end +end + +function __bobthefish_prompt_vi -S -d 'Display vi mode' + [ "$theme_display_vi" != 'no' ] + or return + + [ "$fish_key_bindings" = 'fish_vi_key_bindings' \ + -o "$fish_key_bindings" = 'hybrid_bindings' \ + -o "$fish_key_bindings" = 'fish_hybrid_key_bindings' \ + -o "$theme_display_vi" = 'yes' ] + or return + + switch $fish_bind_mode + case default + __bobthefish_start_segment $color_vi_mode_default + echo -n 'N ' + case insert + __bobthefish_start_segment $color_vi_mode_insert + echo -n 'I ' + case replace_one replace-one + __bobthefish_start_segment $color_vi_mode_insert + echo -n 'R ' + case visual + __bobthefish_start_segment $color_vi_mode_visual + echo -n 'V ' + end +end + + +# ============================== +# Container and VM segments +# ============================== + +function __bobthefish_prompt_vagrant -S -d 'Display Vagrant status' + [ "$theme_display_vagrant" = 'yes' -a -f Vagrantfile ] + or return + + # .vagrant/machines/$machine/$provider/id + for file in .vagrant/machines/*/*/id + read -l id <"$file" + + if [ -n "$id" ] + switch "$file" + case '*/virtualbox/id' + __bobthefish_prompt_vagrant_vbox $id + case '*/vmware_fusion/id' + __bobthefish_prompt_vagrant_vmware $id + case '*/parallels/id' + __bobthefish_prompt_vagrant_parallels $id + end + end + end +end + +function __bobthefish_prompt_vagrant_vbox -S -a id -d 'Display VirtualBox Vagrant status' + set -l vagrant_status + set -l vm_status (VBoxManage showvminfo --machinereadable $id 2>/dev/null | command grep 'VMState=' | tr -d '"' | cut -d '=' -f 2) + + switch "$vm_status" + case 'running' + set vagrant_status "$vagrant_status$vagrant_running_glyph" + case 'poweroff' + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" + case 'aborted' + set vagrant_status "$vagrant_status$vagrant_aborted_glyph" + case 'saved' + set vagrant_status "$vagrant_status$vagrant_saved_glyph" + case 'stopping' + set vagrant_status "$vagrant_status$vagrant_stopping_glyph" + case '' + set vagrant_status "$vagrant_status$vagrant_unknown_glyph" + end + + [ -z "$vagrant_status" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_status ' ' +end + +function __bobthefish_prompt_vagrant_vmware -S -a id -d 'Display VMWare Vagrant status' + set -l vagrant_status + if [ (pgrep -f "$id") ] + set vagrant_status "$vagrant_status$vagrant_running_glyph" + else + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" + end + + [ -z "$vagrant_status" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_status ' ' +end + +function __bobthefish_prompt_vagrant_parallels -S -d 'Display Parallels Vagrant status' + set -l vagrant_status + set -l vm_status (prlctl list $id -o status 2>/dev/null | command tail -1) + + switch "$vm_status" + case 'running' + set vagrant_status "$vagrant_status$vagrant_running_glyph" + case 'stopped' + set vagrant_status "$vagrant_status$vagrant_poweroff_glyph" + case 'paused' + set vagrant_status "$vagrant_status$vagrant_saved_glyph" + case 'suspended' + set vagrant_status "$vagrant_status$vagrant_saved_glyph" + case 'stopping' + set vagrant_status "$vagrant_status$vagrant_stopping_glyph" + case '' + set vagrant_status "$vagrant_status$vagrant_unknown_glyph" + end + + [ -z "$vagrant_status" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $vagrant_status ' ' +end + +function __bobthefish_prompt_docker -S -d 'Display Docker machine name' + [ "$theme_display_docker_machine" = 'no' -o -z "$DOCKER_MACHINE_NAME" ] + and return + + __bobthefish_start_segment $color_vagrant + echo -ns $DOCKER_MACHINE_NAME ' ' +end + +function __bobthefish_k8s_context -S -d 'Get the current k8s context' + set -l config_paths "$HOME/.kube/config" + [ -n "$KUBECONFIG" ] + and set config_paths (string split ':' "$KUBECONFIG") $config_paths + + for file in $config_paths + [ -f "$file" ] + or continue + + while read -l key val + if [ "$key" = 'current-context:' ] + set -l context (string trim -c '"\' ' -- $val) + [ -z "$context" ] + and return 1 + + echo $context + return + end + end <$file + end + + return 1 +end + +function __bobthefish_k8s_namespace -S -d 'Get the current k8s namespace' + kubectl config view --minify --output "jsonpath={..namespace}" +end + +function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context' + [ "$theme_display_k8s_context" = 'yes' ] + or return + + set -l context (__bobthefish_k8s_context) + or return + + [ "$theme_display_k8s_namespace" = 'yes' ] + and set -l namespace (__bobthefish_k8s_namespace) + + set -l segment $k8s_glyph " " $context + [ -n "$namespace" ] + and set segment $segment ":" $namespace + + __bobthefish_start_segment $color_k8s + echo -ns $segment " " +end + + +# ============================== +# User / hostname info segments +# ============================== + +# Polyfill for fish < 2.5.0 +if not type -q prompt_hostname + if not set -q __bobthefish_prompt_hostname + set -g __bobthefish_prompt_hostname (hostname | string replace -r '\..*' '') + end + + function prompt_hostname + echo $__bobthefish_prompt_hostname + end +end + +function __bobthefish_prompt_user -S -d 'Display current user and hostname' + [ "$theme_display_user" = 'yes' -o \( "$theme_display_user" != 'no' -a -n "$SSH_CLIENT" \) -o \( -n "$default_user" -a "$USER" != "$default_user" \) ] + and set -l display_user + + [ "$theme_display_sudo_user" = 'yes' -a -n "$SUDO_USER" ] + and set -l display_sudo_user + + [ "$theme_display_hostname" = 'yes' -o \( "$theme_display_hostname" != 'no' -a -n "$SSH_CLIENT" \) ] + and set -l display_hostname + + if set -q display_user + __bobthefish_start_segment $color_username + echo -ns (whoami) + end + + if set -q display_sudo_user + if set -q display_user + echo -ns ' ' + else + __bobthefish_start_segment $color_username + end + echo -ns "($SUDO_USER)" + end + + if set -q display_hostname + if set -q display_user + or set -q display_sudo_user + # reset colors without starting a new segment... + # (so we can have a bold username and non-bold hostname) + set_color normal + set_color -b $color_hostname[1] $color_hostname[2..-1] + echo -ns '@' (prompt_hostname) + else + __bobthefish_start_segment $color_hostname + echo -ns (prompt_hostname) + end + end + + set -q display_user + or set -q display_sudo_user + or set -q display_hostname + and echo -ns ' ' +end + + +# ============================== +# Virtual environment segments +# ============================== + +function __bobthefish_rvm_parse_ruby -S -a ruby_string -a scope -d 'Parse RVM Ruby string' + # Function arguments: + # - 'ruby-2.2.3@rails', 'jruby-1.7.19'... + # - 'default' or 'current' + set -l IFS @ + echo "$ruby_string" | read __ruby __rvm_{$scope}_ruby_gemset __ + set IFS - + echo "$__ruby" | read __rvm_{$scope}_ruby_interpreter __rvm_{$scope}_ruby_version __ + set -e __ruby + set -e __ +end + +function __bobthefish_rvm_info -S -d 'Current Ruby information from RVM' + # look for rvm install path + set -q rvm_path + or set -l rvm_path ~/.rvm /usr/local/rvm + + # More `sed`/`grep`/`cut` magic... + set -l __rvm_default_ruby (grep GEM_HOME $rvm_path/environments/default 2>/dev/null | sed -e"s/'//g" | sed -e's/.*\///') + set -l __rvm_current_ruby (rvm-prompt i v g) + + [ "$__rvm_default_ruby" = "$__rvm_current_ruby" ] + and return + + set -l __rvm_default_ruby_gemset + set -l __rvm_default_ruby_interpreter + set -l __rvm_default_ruby_version + set -l __rvm_current_ruby_gemset + set -l __rvm_current_ruby_interpreter + set -l __rvm_current_ruby_version + + # Parse default and current Rubies to global variables + __bobthefish_rvm_parse_ruby $__rvm_default_ruby default + __bobthefish_rvm_parse_ruby $__rvm_current_ruby current + # Show unobtrusive RVM prompt + + # If interpreter differs form default interpreter, show everything: + if [ "$__rvm_default_ruby_interpreter" != "$__rvm_current_ruby_interpreter" ] + if [ "$__rvm_current_ruby_gemset" = 'global' ] + rvm-prompt i v + else + rvm-prompt i v g + end + # If version differs form default version + else if [ "$__rvm_default_ruby_version" != "$__rvm_current_ruby_version" ] + if [ "$__rvm_current_ruby_gemset" = 'global' ] + rvm-prompt v + else + rvm-prompt v g + end + # If gemset differs form default or 'global' gemset, just show it + else if [ "$__rvm_default_ruby_gemset" != "$__rvm_current_ruby_gemset" ] + rvm-prompt g + end +end + +function __bobthefish_prompt_rubies -S -d 'Display current Ruby information' + [ "$theme_display_ruby" = 'no' ] + and return + + set -l ruby_version + if type -fq rvm-prompt + set ruby_version (__bobthefish_rvm_info) + else if type -fq rbenv + set ruby_version (rbenv version-name) + # Don't show global ruby version... + set -q RBENV_ROOT + or set -l RBENV_ROOT $HOME/.rbenv + + [ -e "$RBENV_ROOT/version" ] + and read -l global_ruby_version <"$RBENV_ROOT/version" + + [ "$global_ruby_version" ] + or set -l global_ruby_version system + + [ "$ruby_version" = "$global_ruby_version" ] + and return + else if type -q chruby # chruby is implemented as a function, so omitting the -f is intentional + set ruby_version $RUBY_VERSION + else if type -fq asdf + asdf current ruby 2>/dev/null | read -l asdf_ruby_version asdf_provenance + or return + + # If asdf changes their ruby version provenance format, update this to match + [ "$asdf_provenance" = "(set by $HOME/.tool-versions)" ] + and return + + set ruby_version $asdf_ruby_version + end + + [ -z "$ruby_version" ] + and return + + __bobthefish_start_segment $color_rvm + echo -ns $ruby_glyph $ruby_version ' ' +end + +function __bobthefish_virtualenv_python_version -S -d 'Get current Python version' + switch (python --version 2>&1 | tr '\n' ' ') + case 'Python 2*PyPy*' + echo $pypy_glyph + case 'Python 3*PyPy*' + echo -s $pypy_glyph $superscript_glyph[3] + case 'Python 2*' + echo $superscript_glyph[2] + case 'Python 3*' + echo $superscript_glyph[3] + end +end + +function __bobthefish_prompt_virtualfish -S -d "Display current Python virtual environment (only for virtualfish, virtualenv's activate.fish changes prompt by itself) or conda environment." + [ "$theme_display_virtualenv" = 'no' -o -z "$VIRTUAL_ENV" -a -z "$CONDA_DEFAULT_ENV" ] + and return + + set -l version_glyph (__bobthefish_virtualenv_python_version) + + if [ "$version_glyph" ] + __bobthefish_start_segment $color_virtualfish + echo -ns $virtualenv_glyph $version_glyph ' ' + end + + if [ "$VIRTUAL_ENV" ] + echo -ns (basename "$VIRTUAL_ENV") ' ' + else if [ "$CONDA_DEFAULT_ENV" ] + echo -ns (basename "$CONDA_DEFAULT_ENV") ' ' + end +end + +function __bobthefish_prompt_virtualgo -S -d 'Display current Go virtual environment' + [ "$theme_display_virtualgo" = 'no' -o -z "$VIRTUALGO" ] + and return + + __bobthefish_start_segment $color_virtualgo + echo -ns $go_glyph ' ' (basename "$VIRTUALGO") ' ' + set_color normal +end + +function __bobthefish_prompt_desk -S -d 'Display current desk environment' + [ "$theme_display_desk" = 'no' -o -z "$DESK_ENV" ] + and return + + __bobthefish_start_segment $color_desk + echo -ns $desk_glyph ' ' (basename -a -s ".fish" "$DESK_ENV") ' ' + set_color normal +end + +function __bobthefish_prompt_nvm -S -d 'Display current node version through NVM' + [ "$theme_display_nvm" = 'yes' -a -n "$NVM_DIR" ] + or return + + set -l node_version (nvm current 2> /dev/null) + + [ -z $node_version -o "$node_version" = 'none' -o "$node_version" = 'system' ] + and return + + __bobthefish_start_segment $color_nvm + echo -ns $node_glyph $node_version ' ' + set_color normal +end + + +# ============================== +# VCS segments +# ============================== + +function __bobthefish_prompt_hg -S -a hg_root_dir -a real_pwd -d 'Display the actual hg state' + set -l dirty (command hg stat; or echo -n '*') + + set -l flags "$dirty" + [ "$flags" ] + and set flags "" + + set -l flag_colors $color_repo + if [ "$dirty" ] + set flag_colors $color_repo_dirty + end + + __bobthefish_path_segment $hg_root_dir + + __bobthefish_start_segment $flag_colors + echo -ns $hg_glyph ' ' + + __bobthefish_start_segment $flag_colors + echo -ns (__bobthefish_hg_branch) $flags ' ' + set_color normal + + set -l project_pwd (__bobthefish_project_pwd $hg_root_dir $real_pwd) + if [ "$project_pwd" ] + if [ -w "$real_pwd" ] + __bobthefish_start_segment $color_path + else + __bobthefish_start_segment $color_path_nowrite + end + + echo -ns $project_pwd ' ' + end +end + +function __bobthefish_prompt_git -S -a git_root_dir -a real_pwd -d 'Display the actual git state' + set -l dirty '' + if [ "$theme_display_git_dirty" != 'no' ] + set -l show_dirty (command git config --bool bash.showDirtyState 2>/dev/null) + if [ "$show_dirty" != 'false' ] + set dirty (command git diff --no-ext-diff --quiet --exit-code 2>/dev/null; or echo -n "$git_dirty_glyph") + if [ "$dirty" -a "$theme_display_git_dirty_verbose" = 'yes' ] + set dirty "$dirty"(__bobthefish_git_dirty_verbose) + end + end + end + + set -l staged (command git diff --cached --no-ext-diff --quiet --exit-code 2>/dev/null; or echo -n "$git_staged_glyph") + set -l stashed (__bobthefish_git_stashed) + set -l ahead (__bobthefish_git_ahead) + + set -l new '' + if [ "$theme_display_git_untracked" != 'no' ] + set -l show_untracked (command git config --bool bash.showUntrackedFiles 2>/dev/null) + if [ "$show_untracked" != 'false' ] + set new (command git ls-files --other --exclude-standard --directory --no-empty-directory 2>/dev/null) + if [ "$new" ] + set new "$git_untracked_glyph" + end + end + end + + set -l flags "$dirty$staged$stashed$ahead$new" + + [ "$flags" ] + and set flags " $flags" + + set -l flag_colors $color_repo + if [ "$dirty" ] + set flag_colors $color_repo_dirty + else if [ "$staged" ] + set flag_colors $color_repo_staged + end + + __bobthefish_path_segment $git_root_dir + + __bobthefish_start_segment $flag_colors + echo -ns (__bobthefish_git_branch) $flags ' ' + set_color normal + + if [ "$theme_git_worktree_support" != 'yes' ] + set -l project_pwd (__bobthefish_project_pwd $git_root_dir $real_pwd) + if [ "$project_pwd" ] + if [ -w "$real_pwd" ] + __bobthefish_start_segment $color_path + else + __bobthefish_start_segment $color_path_nowrite + end + + echo -ns $project_pwd ' ' + end + return + end + + set -l project_pwd (command git rev-parse --show-prefix 2>/dev/null | string trim --right --chars=/) + set -l work_dir (command git rev-parse --show-toplevel 2>/dev/null) + + # only show work dir if it's a parent… + if [ "$work_dir" ] + switch $real_pwd/ + case $work_dir/\* + string match "$git_root_dir*" $work_dir >/dev/null + and set work_dir (string sub -s (math 1 + (string length $git_root_dir)) $work_dir) + case \* + set -e work_dir + end + end + + if [ "$project_pwd" -o "$work_dir" ] + set -l colors $color_path + if not [ -w "$real_pwd" ] + set colors $color_path_nowrite + end + + __bobthefish_start_segment $colors + + # handle work_dir != project dir + if [ "$work_dir" ] + set -l work_parent (__bobthefish_dirname $work_dir) + if [ "$work_parent" ] + echo -n "$work_parent/" + end + + set_color normal + set_color -b $color_repo_work_tree + echo -n (__bobthefish_basename $work_dir) + + set_color normal + set_color -b $colors + [ "$project_pwd" ] + and echo -n '/' + end + + echo -ns $project_pwd ' ' + else + set project_pwd $real_pwd + + string match "$git_root_dir*" $project_pwd >/dev/null + and set project_pwd (string sub -s (math 1 + (string length $git_root_dir)) $project_pwd) + + set project_pwd (string trim --left --chars=/ -- $project_pwd) + + if [ "$project_pwd" ] + set -l colors $color_path + if not [ -w "$real_pwd" ] + set colors $color_path_nowrite + end + + __bobthefish_start_segment $colors + + echo -ns $project_pwd ' ' + end + end +end + +function __bobthefish_prompt_dir -S -a real_pwd -d 'Display a shortened form of the current directory' + __bobthefish_path_segment "$real_pwd" +end + + +# ============================== +# Apply theme +# ============================== + +function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' + # Save the last status for later (do this before anything else) + set -l last_status $status + + # Use a simple prompt on dumb terminals. + if [ "$TERM" = "dumb" ] + echo "> " + return + end + + __bobthefish_glyphs + __bobthefish_colors $theme_color_scheme + + type -q bobthefish_colors + and bobthefish_colors + + # Start each line with a blank slate + set -l __bobthefish_current_bg + + # Status flags and input mode + __bobthefish_prompt_status $last_status + __bobthefish_prompt_vi + + # User / hostname info + __bobthefish_prompt_user + + # Containers and VMs + __bobthefish_prompt_vagrant + __bobthefish_prompt_docker + __bobthefish_prompt_k8s_context + + # Virtual environments + __bobthefish_prompt_desk + __bobthefish_prompt_rubies + __bobthefish_prompt_virtualfish + __bobthefish_prompt_virtualgo + __bobthefish_prompt_nvm + + set -l real_pwd (__bobthefish_pwd) + + # VCS + set -l git_root_dir (__bobthefish_git_project_dir $real_pwd) + set -l hg_root_dir (__bobthefish_hg_project_dir $real_pwd) + + if [ "$git_root_dir" -a "$hg_root_dir" ] + # only show the closest parent + switch $git_root_dir + case $hg_root_dir\* + __bobthefish_prompt_git $git_root_dir $real_pwd + case \* + __bobthefish_prompt_hg $hg_root_dir $real_pwd + end + else if [ "$git_root_dir" ] + __bobthefish_prompt_git $git_root_dir $real_pwd + else if [ "$hg_root_dir" ] + __bobthefish_prompt_hg $hg_root_dir $real_pwd + else + __bobthefish_prompt_dir $real_pwd + end + + __bobthefish_finish_segments +end diff --git a/.config/fish/functions/fish_right_prompt.fish b/.config/fish/functions/fish_right_prompt.fish new file mode 100644 index 0000000..d0bb3b1 --- /dev/null +++ b/.config/fish/functions/fish_right_prompt.fish @@ -0,0 +1,79 @@ +# You can override some default right prompt options in your config.fish: +# set -g theme_date_format "+%a %H:%M" + +function __bobthefish_cmd_duration -S -d 'Show command duration' + [ "$theme_display_cmd_duration" = "no" ] + and return + + [ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ] + and return + + if [ "$CMD_DURATION" -lt 5000 ] + echo -ns $CMD_DURATION 'ms' + else if [ "$CMD_DURATION" -lt 60000 ] + __bobthefish_pretty_ms $CMD_DURATION s + else if [ "$CMD_DURATION" -lt 3600000 ] + set_color $fish_color_error + __bobthefish_pretty_ms $CMD_DURATION m + else + set_color $fish_color_error + __bobthefish_pretty_ms $CMD_DURATION h + end + + set_color $fish_color_normal + set_color $fish_color_autosuggestion + + [ "$theme_display_date" = "no" ] + or echo -ns ' ' $__bobthefish_left_arrow_glyph +end + +function __bobthefish_pretty_ms -S -a ms -a interval -d 'Millisecond formatting for humans' + set -l interval_ms + set -l scale 1 + + switch $interval + case s + set interval_ms 1000 + case m + set interval_ms 60000 + case h + set interval_ms 3600000 + set scale 2 + end + + switch $FISH_VERSION + case 2.0.\* 2.1.\* 2.2.\* 2.3.\* + # Fish 2.3 and lower doesn't know about the -s argument to math. + math "scale=$scale;$ms/$interval_ms" | string replace -r '\\.?0*$' $interval + case 2.\* + # Fish 2.x always returned a float when given the -s argument. + math -s$scale "$ms/$interval_ms" | string replace -r '\\.?0*$' $interval + case \* + math -s$scale "$ms/$interval_ms" + echo -ns $interval + end +end + +function __bobthefish_timestamp -S -d 'Show the current timestamp' + [ "$theme_display_date" = "no" ] + and return + + set -q theme_date_format + or set -l theme_date_format "+%c" + + echo -n ' ' + date $theme_date_format +end + +function fish_right_prompt -d 'bobthefish is all about the right prompt' + set -l __bobthefish_left_arrow_glyph \uE0B3 + if [ "$theme_powerline_fonts" = "no" ] + set __bobthefish_left_arrow_glyph '<' + end + + set_color $fish_color_autosuggestion + + __bobthefish_cmd_duration + __bobthefish_timestamp + set_color normal +end diff --git a/.config/fish/functions/fish_title.fish b/.config/fish/functions/fish_title.fish new file mode 100644 index 0000000..a14e1b6 --- /dev/null +++ b/.config/fish/functions/fish_title.fish @@ -0,0 +1,34 @@ +# You can override some default title options in your config.fish: +# set -g theme_title_display_process no +# set -g theme_title_display_path no +# set -g theme_title_display_user yes +# set -g theme_title_use_abbreviated_path no + +function __bobthefish_title_user -S -d 'Display actual user if different from $default_user' + if [ "$theme_title_display_user" = 'yes' ] + if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ] + set -l IFS . + hostname | read -l hostname __ + echo -ns (whoami) '@' $hostname ' ' + end + end +end + +function fish_title + __bobthefish_title_user + + if [ "$theme_title_display_process" = 'yes' ] + echo $_ + + [ "$theme_title_display_path" != 'no' ] + and echo ' ' + end + + if [ "$theme_title_display_path" != 'no' ] + if [ "$theme_title_use_abbreviated_path" = 'no' ] + echo $PWD + else + prompt_pwd + end + end +end diff --git a/.config/fish/functions/fish_user_key_bindings.fish b/.config/fish/functions/fish_user_key_bindings.fish new file mode 100644 index 0000000..350a9da --- /dev/null +++ b/.config/fish/functions/fish_user_key_bindings.fish @@ -0,0 +1,3 @@ +function fish_user_key_bindings + fzf_key_bindings +end diff --git a/.config/fish/functions/fisher.fish b/.config/fish/functions/fisher.fish new file mode 100644 index 0000000..1d63c33 --- /dev/null +++ b/.config/fish/functions/fisher.fish @@ -0,0 +1,435 @@ +set -g fisher_version 3.2.10 + +function fisher -a cmd -d "fish package manager" + set -q XDG_CACHE_HOME; or set XDG_CACHE_HOME ~/.cache + set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config + + set -g fish_config $XDG_CONFIG_HOME/fish + set -g fisher_cache $XDG_CACHE_HOME/fisher + set -g fisher_config $XDG_CONFIG_HOME/fisher + + set -q fisher_path; or set -g fisher_path $fish_config + set -g fishfile $fish_config/fishfile + + for path in {$fish_config,$fisher_path}/{functions,completions,conf.d} $fisher_cache + if test ! -d $path + command mkdir -p $path + end + end + + if test ! -e $fisher_path/completions/fisher.fish + echo "fisher complete" >$fisher_path/completions/fisher.fish + _fisher_complete + end + + if test -e $fisher_path/conf.d/fisher.fish + switch "$version" + case \*-\* + command rm -f $fisher_path/conf.d/fisher.fish + case 2\* + case \* + command rm -f $fisher_path/conf.d/fisher.fish + end + else + switch "$version" + case \*-\* + case 2\* + echo "fisher copy-user-key-bindings" >$fisher_path/conf.d/fisher.fish + end + end + + # 2019-10-22: temp code, migrates fishfile from old path back to $fish_config + if test -e "$fisher_path/fishfile"; and test ! -e "$fishfile" + command mv -f "$fisher_path/fishfile" "$fishfile" + end + + switch "$cmd" + case {,self-}complete + _fisher_complete + case copy-user-key-bindings + _fisher_copy_user_key_bindings + case ls + set -e argv[1] + if test -s "$fishfile" + set -l file (_fisher_fmt <$fishfile | _fisher_parse -R | command sed "s|@.*||") + _fisher_ls | _fisher_fmt | command awk -v FILE="$file" " + BEGIN { for (n = split(FILE, f); ++i <= n;) file[f[i]] } \$0 in file && /$argv[1]/ + " | command sed "s|^$HOME|~|" + end + case self-update + _fisher_self_update (status -f) + case self-uninstall + _fisher_self_uninstall + case {,-}-v{ersion,} + echo "fisher version $fisher_version" (status -f | command sed "s|^$HOME|~|") + case {,-}-h{elp,} + _fisher_help + case "" + _fisher_commit -- + case add rm + if not isatty + while read -l arg + set argv $argv $arg + end + end + + if test (count $argv) = 1 + echo "fisher: invalid number of arguments" >&2 + _fisher_help >&2 + return 1 + end + + _fisher_commit $argv + case \* + echo "fisher: unknown flag or command \"$cmd\"" >&2 + _fisher_help >&2 + return 1 + end +end + +function _fisher_complete + complete -ec fisher + complete -xc fisher -n __fish_use_subcommand -a add -d "Add packages" + complete -xc fisher -n __fish_use_subcommand -a rm -d "Remove packages" + complete -xc fisher -n __fish_use_subcommand -a ls -d "List installed packages matching REGEX" + complete -xc fisher -n __fish_use_subcommand -a --help -d "Show usage help" + complete -xc fisher -n __fish_use_subcommand -a --version -d "$fisher_version" + complete -xc fisher -n __fish_use_subcommand -a self-update -d "Update to the latest version" + for pkg in (fisher ls) + complete -xc fisher -n "__fish_seen_subcommand_from rm" -a $pkg + end +end + +function _fisher_copy_user_key_bindings + if functions -q fish_user_key_bindings + functions -c fish_user_key_bindings fish_user_key_bindings_copy + end + function fish_user_key_bindings + for file in $fisher_path/conf.d/*_key_bindings.fish + source $file >/dev/null 2>/dev/null + end + if functions -q fish_user_key_bindings_copy + fish_user_key_bindings_copy + end + end +end + +function _fisher_ls + for pkg in $fisher_config/*/*/* + command readlink $pkg; or echo $pkg + end +end + +function _fisher_fmt + command sed "s|^[[:space:]]*||;s|^$fisher_config/||;s|^~|$HOME|;s|^\.\/*|$PWD/|;s|^https*:/*||;s|^github\.com/||;s|/*\$||" +end + +function _fisher_help + echo "usage: fisher add Add packages" + echo " fisher rm Remove packages" + echo " fisher Update all packages" + echo " fisher ls [] List installed packages matching " + echo " fisher --help Show this help" + echo " fisher --version Show the current version" + echo " fisher self-update Update to the latest version" + echo " fisher self-uninstall Uninstall from your system" + echo "examples:" + echo " fisher add jethrokuan/z rafaelrinaldi/pure" + echo " fisher add gitlab.com/foo/bar@v2" + echo " fisher add ~/path/to/local/pkg" + echo " fisher add &2 + command curl -s "$url?nocache" >$file. + + set -l next_version (command awk '{ print $4 } { exit }' <$file.) + switch "$next_version" + case "" $fisher_version + command rm -f $file. + if test -z "$next_version" + echo "fisher: cannot update fisher -- are you offline?" >&2 + return 1 + end + echo "fisher is already up-to-date" >&2 + case \* + echo "linking $file" | command sed "s|$HOME|~|" >&2 + command mv -f $file. $file + source $file + echo "updated to fisher $fisher_version -- hooray!" >&2 + _fisher_complete + end +end + +function _fisher_self_uninstall + for pkg in (_fisher_ls) + _fisher_rm $pkg + end + + for file in $fisher_cache $fisher_config $fisher_path/{functions,completions,conf.d}/fisher.fish $fishfile + echo "removing $file" + command rm -Rf $file 2>/dev/null + end | command sed "s|$HOME|~|" >&2 + + for name in (set -n | command awk '/^fisher_/') + set -e "$name" + end + + functions -e (functions -a | command awk '/^_fisher/') fisher + complete -c fisher --erase +end + +function _fisher_commit -a cmd + set -e argv[1] + set -l elapsed (_fisher_now) + + if test ! -e "$fishfile" + command touch $fishfile + echo "created new fishfile in $fishfile" | command sed "s|$HOME|~|" >&2 + end + + set -l old_pkgs (_fisher_ls | _fisher_fmt) + for pkg in (_fisher_ls) + _fisher_rm $pkg + end + command rm -Rf $fisher_config + command mkdir -p $fisher_config + + set -l next_pkgs (_fisher_fmt <$fishfile | _fisher_parse -R $cmd (printf "%s\n" $argv | _fisher_fmt)) + set -l actual_pkgs (_fisher_fetch $next_pkgs) + set -l updated_pkgs + for pkg in $old_pkgs + if contains -- $pkg $actual_pkgs + set updated_pkgs $updated_pkgs $pkg + end + end + + if test -z "$actual_pkgs$updated_pkgs$old_pkgs$next_pkgs" + echo "fisher: nothing to commit -- try adding some packages" >&2 + return 1 + end + + set -l out_pkgs + if test "$cmd" = "rm" + set out_pkgs $next_pkgs + else + for pkg in $next_pkgs + if contains -- (echo $pkg | command sed "s|@.*||") $actual_pkgs + set out_pkgs $out_pkgs $pkg + end + end + end + + printf "%s\n" (_fisher_fmt <$fishfile | _fisher_parse -W $cmd $out_pkgs | command sed "s|^$HOME|~|") >$fishfile + + _fisher_complete + + command awk -v A=(count $actual_pkgs) -v U=(count $updated_pkgs) -v O=(count $old_pkgs) -v E=(_fisher_now $elapsed) ' + BEGIN { + res = fmt("removed", O - U, fmt("updated", U, fmt("added", A - U))) + printf((res ? res : "done") " in %.2fs\n", E / 1000) + } + function fmt(action, n, s) { + return n ? (s ? s ", " : s) action " " n " package" (n > 1 ? "s" : "") : s + } + ' >&2 +end + +function _fisher_parse -a mode cmd + set -e argv[1..2] + command awk -v FS="[[:space:]]*#+" -v MODE="$mode" -v CMD="$cmd" -v ARGSTR="$argv" ' + BEGIN { + for (n = split(ARGSTR, a, " "); i++ < n;) pkgs[getkey(a[i])] = a[i] + } + !NF { next } { k = getkey($1) } + MODE == "-R" && !(k in pkgs) && $0 = $1 + MODE == "-W" && (/^#/ || k in pkgs || CMD != "rm") { print pkgs[k] (sub($1, "") ? $0 : "") } + MODE == "-W" || CMD == "rm" { delete pkgs[k] } + END { + for (k in pkgs) { + if (CMD != "rm" || MODE == "-W") print pkgs[k] + else print "fisher: cannot remove \""k"\" -- package is not in fishfile" > "/dev/stderr" + } + } + function getkey(s, a) { + return (split(s, a, /@+|:/) > 2) ? a[2]"/"a[1]"/"a[3] : a[1] + } + ' +end + +function _fisher_fetch + set -l pkg_jobs + set -l out_pkgs + set -l next_pkgs + set -l local_pkgs + set -q fisher_user_api_token; and set -l curl_opts -u $fisher_user_api_token + + for pkg in $argv + switch $pkg + case \~\* /\* + set -l path (echo "$pkg" | command sed "s|^~|$HOME|") + if test -e "$path" + set local_pkgs $local_pkgs $path + else + echo "fisher: cannot add \"$pkg\" -- is this a valid file?" >&2 + end + continue + end + + command awk -v PKG="$pkg" -v FS=/ ' + BEGIN { + if (split(PKG, tmp, /@+|:/) > 2) { + if (tmp[4]) sub("@"tmp[4], "", PKG) + print PKG "\t" tmp[2]"/"tmp[1]"/"tmp[3] "\t" (tmp[4] ? tmp[4] : "master") + } else { + pkg = split(PKG, _, "/") <= 2 ? "github.com/"tmp[1] : tmp[1] + tag = tmp[2] ? tmp[2] : "master" + print (\ + pkg ~ /^github/ ? "https://codeload."pkg"/tar.gz/"tag : \ + pkg ~ /^gitlab/ ? "https://"pkg"/-/archive/"tag"/"tmp[split(pkg, tmp, "/")]"-"tag".tar.gz" : \ + pkg ~ /^bitbucket/ ? "https://"pkg"/get/"tag".tar.gz" : pkg \ + ) "\t" pkg + } + } + ' | read -l url pkg branch + + if test ! -d "$fisher_config/$pkg" + fish -c " + echo fetching $url >&2 + command mkdir -p $fisher_config/$pkg $fisher_cache/(command dirname $pkg) + if test ! -z \"$branch\" + command git clone $url $fisher_config/$pkg --branch $branch --depth 1 2>/dev/null + or echo fisher: cannot clone \"$url\" -- is this a valid url\? >&2 + else if command curl $curl_opts -Ss -w \"\" $url 2>&1 | command tar -xzf- -C $fisher_config/$pkg 2>/dev/null + command rm -Rf $fisher_cache/$pkg + command mv -f $fisher_config/$pkg/* $fisher_cache/$pkg + command rm -Rf $fisher_config/$pkg + command cp -Rf {$fisher_cache,$fisher_config}/$pkg + else if test -d \"$fisher_cache/$pkg\" + echo fisher: cannot connect to server -- looking in \"$fisher_cache/$pkg\" | command sed 's|$HOME|~|' >&2 + command cp -Rf $fisher_cache/$pkg $fisher_config/$pkg/.. + else + command rm -Rf $fisher_config/$pkg + echo fisher: cannot add \"$pkg\" -- is this a valid package\? >&2 + end + " >/dev/null & + set pkg_jobs $pkg_jobs (_fisher_jobs --last) + set next_pkgs $next_pkgs "$fisher_config/$pkg" + end + end + + if set -q pkg_jobs[1] + while for job in $pkg_jobs + contains -- $job (_fisher_jobs); and break + end + end + for pkg in $next_pkgs + if test -d "$pkg" + set out_pkgs $out_pkgs $pkg + _fisher_add $pkg + end + end + end + + set -l local_prefix $fisher_config/local/$USER + if test ! -d "$local_prefix" + command mkdir -p $local_prefix + end + for pkg in $local_pkgs + set -l target $local_prefix/(command basename $pkg) + if test ! -L "$target" + command ln -sf $pkg $target + set out_pkgs $out_pkgs $pkg + _fisher_add $pkg --link + end + end + + if set -q out_pkgs[1] + _fisher_fetch ( + for pkg in $out_pkgs + if test -s "$pkg/fishfile" + _fisher_fmt <$pkg/fishfile | _fisher_parse -R + end + end) + printf "%s\n" $out_pkgs | _fisher_fmt + end +end + +function _fisher_add -a pkg opts + for src in $pkg/{functions,completions,conf.d}/**.* $pkg/*.fish + set -l target (command basename $src) + switch $src + case $pkg/conf.d\* + set target $fisher_path/conf.d/$target + case $pkg/completions\* + set target $fisher_path/completions/$target + case $pkg/{functions,}\* + switch $target + case uninstall.fish + continue + case {init,key_bindings}.fish + set target $fisher_path/conf.d/(command basename $pkg)\_$target + case \* + set target $fisher_path/functions/$target + end + end + echo "linking $target" | command sed "s|$HOME|~|" >&2 + if set -q opts[1] + command ln -sf $src $target + else + command cp -f $src $target + end + switch $target + case \*.fish + source $target >/dev/null 2>/dev/null + end + end +end + +function _fisher_rm -a pkg + for src in $pkg/{conf.d,completions,functions}/**.* $pkg/*.fish + set -l target (command basename $src) + set -l filename (command basename $target .fish) + switch $src + case $pkg/conf.d\* + test "$filename.fish" = "$target"; and emit "$filename"_uninstall + set target conf.d/$target + case $pkg/completions\* + test "$filename.fish" = "$target"; and complete -ec $filename + set target completions/$target + case $pkg/{,functions}\* + test "$filename.fish" = "$target"; and functions -e $filename + switch $target + case uninstall.fish + source $src + continue + case {init,key_bindings}.fish + set target conf.d/(command basename $pkg)\_$target + case \* + set target functions/$target + end + end + command rm -f $fisher_path/$target + end + if not functions -q fish_prompt + source "$__fish_datadir$__fish_data_dir/functions/fish_prompt.fish" + end +end + +function _fisher_jobs + jobs $argv | command awk '/^[0-9]+\t/ { print $1 }' +end + +function _fisher_now -a elapsed + switch (command uname) + case Darwin \*BSD + command perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - $ARGV[0])' $elapsed + case \* + math (command date "+%s%3N") - "0$elapsed" + end +end diff --git a/.config/fish/functions/fzf_key_bindings.fish b/.config/fish/functions/fzf_key_bindings.fish new file mode 120000 index 0000000..a5e0b96 --- /dev/null +++ b/.config/fish/functions/fzf_key_bindings.fish @@ -0,0 +1 @@ +/home/marc/.fzf/shell/key-bindings.fish \ No newline at end of file diff --git a/.config/i3/config b/.config/i3/config new file mode 100644 index 0000000..52b535e --- /dev/null +++ b/.config/i3/config @@ -0,0 +1,260 @@ +# This file has been auto-generated by i3-config-wizard(1). +# It will not be overwritten, so edit it as you like. +# +# Should you change your keyboard layout some time, delete +# this file and re-run i3-config-wizard(1). +# + +# i3 config file (v4) +# +# Please see https://i3wm.org/docs/userguide.html for a complete reference! + +set $mod Mod4 + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +# font pango:monospace 8 + +# This font is widely installed, provides lots of unicode glyphs, right-to-left +# text rendering and scalability on retina/hidpi displays (thanks to pango). +font pango:DejaVu Sans Mono 8 + +# Before i3 v4.8, we used to recommend this one as the default: +# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 +# The font above is very space-efficient, that is, it looks good, sharp and +# clear in small sizes. However, its unicode glyph coverage is limited, the old +# X core fonts rendering does not support right-to-left and this being a bitmap +# font, it doesn’t scale on retina/hidpi displays. + +# Configure border style +new_window pixel 1 +new_float normal + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# start a terminal +set $terminal termite +bindsym $mod+Return exec $terminal +bindsym $mod+Shift+Return split v;exec $terminal + +# kill focused window +bindsym $mod+q kill + +# start rofi (a program launcher) +bindsym $mod+space exec --no-startup-id rofi -show run + +focus_follows_mouse no + +# change focus +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l focus right +# alternatively, you can use the cursor keys: +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# change focus (i3-vim compatibility) +# bindsym --release $mod+h exec --no-startup-id "i3-vim-nav h" +# bindsym --release $mod+j exec --no-startup-id "i3-vim-nav j" +# bindsym --release $mod+k exec --no-startup-id "i3-vim-nav k" +# bindsym --release $mod+l exec --no-startup-id "i3-vim-nav l" + +# bindsym --release $mod+Left exec --no-startup-id "i3-vim-nav h" +# bindsym --release $mod+Down exec --no-startup-id "i3-vim-nav j" +# bindsym --release $mod+Up exec --no-startup-id "i3-vim-nav k" +# bindsym --release $mod+Right exec --no-startup-id "i3-vim-nav l" + +# move focused window +bindsym $mod+Shift+h move left +bindsym $mod+Shift+j move down +bindsym $mod+Shift+k move up +bindsym $mod+Shift+l move right + +# alternatively, you can use the cursor keys: +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right + +# split orientation +bindsym $mod+z split h;exec notify-send 'tile horizontally' +bindsym $mod+v split v;exec notify-send 'tile vertically' +# bindsym $mod+q split toggle + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle + +# change focus between tiling / floating windows +# bindsym $mod+space focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +#bindsym $mod+d focus child + +################################################################################################### +#################### WORKSPACES ######################## +################################################################################################### + +# set workspace variables +set $ws1 1 +set $ws2 2 +set $ws3 3 +set $ws4 4 +set $ws5 5 +set $ws6 6 +set $ws7 7 +set $ws8 8 +set $ws9 9 +set $ws10 10 + +# switch to workspace +bindsym $mod+1 workspace $ws1 +bindsym $mod+2 workspace $ws2 +bindsym $mod+3 workspace $ws3 +bindsym $mod+4 workspace $ws4 +bindsym $mod+5 workspace $ws5 +bindsym $mod+6 workspace $ws6 +bindsym $mod+7 workspace $ws7 +bindsym $mod+8 workspace $ws8 +bindsym $mod+9 workspace $ws9 +bindsym $mod+0 workspace $ws10 + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace $ws1; workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2; workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3; workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4; workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5; workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6; workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7; workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8; workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10; workspace $ws10 + +# move workspaces +bindsym $mod+Control+h move workspace to output left +bindsym $mod+Control+Left move workspace to output left +bindsym $mod+Control+l move workspace to output right +bindsym $mod+Control+Right move workspace to output right + +################################################################################################### +#################### WALLPAPER ######################## +################################################################################################### + +exec_always --no-startup-id ~/.config/i3/scripts/wallpapers.sh +exec_always --no-startup-id compton + +################################################################################################### +#################### PROGRAMS ######################## +################################################################################################### + +# Launch programs + +bindsym $mod+Control+1 exec slack +bindsym $mod+Control+3 exec firefox +bindsym $mod+Control+0 exec spotify + +# Assign workspaces +assign [class="Slack"] $ws1 +assign [class="Firefox"] $ws3 +for_window [class="Spotify"] move to workspace $ws10 + +# reload the configuration file +bindsym $mod+Shift+c reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+r restart + +set $Locker i3lock -c 112233 && sleep 1 + +set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +mode "$mode_system" { + bindsym l exec --no-startup-id $Locker, mode "default" + bindsym e exec --no-startup-id i3-msg exit, mode "default" + bindsym s exec --no-startup-id $Locker && systemctl suspend, mode "default" + bindsym h exec --no-startup-id $Locker && systemctl hibernate, mode "default" + bindsym r exec --no-startup-id systemctl reboot, mode "default" + bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default" + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+End mode "$mode_system" +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # Pressing left will shrink the window’s width. + # Pressing right will grow the window’s width. + # Pressing up will shrink the window’s height. + # Pressing down will grow the window’s height. + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize grow height 10 px or 10 ppt + bindsym k resize shrink height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+r mode "resize" + +# Autostart applications +exec_always --no-startup-id $HOME/.config/polybar/launch.sh +exec --no-startup-id ibus-daemon -d -r + +# Pulse Audio controls +bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% #increase sound volume +bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% #decrease sound volume +bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # mute sound + +# Sreen brightness controls +bindsym XF86MonBrightnessUp exec "$HOME/.config/i3/scripts/brightness.sh + eDP-1" +bindsym XF86MonBrightnessDown exec "$HOME/.config/i3/scripts/brightness.sh - eDP-1" + +# Touchpad controls +# bindsym XF86TouchpadToggle exec /some/path/toggletouchpad.sh # toggle touchpad +# Tap touchpad to click +# exec xinput set-prop 12 276 1 + +# Toggle displays +bindsym $mod+p exec --no-startup-id ~/.config/i3/scripts/swap_monitors.sh + +# Media player controls +bindsym XF86AudioPlay exec playerctl play-pause +bindsym XF86AudioPause exec playerctl play-pause +bindsym XF86AudioNext exec playerctl next +bindsym XF86AudioPrev exec playerctl previous + +# Keyboard layout +bindsym $mod+Shift+i exec ~/.config/polybar/scripts/ibus_select.py +bindsym $mod+Shift+Home exec setxkbmap -layout es -variant cat & ibus engine xkb:es:cat:cat + +# Wifi +bindsym $mod+Shift+w exec ~/.config/polybar/scripts/wifi_connect.py + +# Order of screens +exec --no-startup-id xrandr --output DP-2 --right-of eDP-1 +exec --no-startup-id xrandr --output DP-1 --right-of DP-2 diff --git a/.config/i3/scripts/brightness.sh b/.config/i3/scripts/brightness.sh new file mode 100755 index 0000000..1d3307b --- /dev/null +++ b/.config/i3/scripts/brightness.sh @@ -0,0 +1,9 @@ +#!/bin/sh +CURRBRIGHT=$(xrandr --current --verbose | grep -m 1 'Brightness:' | cut -f2- -d:) +if [ "$1" = "+" ] && [ $(echo "$CURRBRIGHT < 1" | bc) -eq 1 ] +then +xrandr --output $2 --brightness $(echo "$CURRBRIGHT + 0.1" | bc) +elif [ "$1" = "-" ] && [ $(echo "$CURRBRIGHT > 0" | bc) -eq 1 ] +then +xrandr --output $2 --brightness $(echo "$CURRBRIGHT - 0.1" | bc) +fi diff --git a/.config/i3/scripts/swap_monitors.sh b/.config/i3/scripts/swap_monitors.sh new file mode 100755 index 0000000..08acdd5 --- /dev/null +++ b/.config/i3/scripts/swap_monitors.sh @@ -0,0 +1,49 @@ +#!/bin/bash +INTERNAL_OUTPUT="eDP-1" + +EXTERNAL_OUTPUT_1="DP-1" +EXTERNAL_OUTPUT_2="DP-2" + +## MONITOR CONFIGURATION + +# .----------. .------------. .------------. +# | | | | | | +# | eDP-1 | | DP-2 | | DP-1 | +# | | | | | | +# '----------' '------------' '------------' +# /_/_/__\_\_\ I I +# /_/_/____\_\_\ _I_ _I_ + + +# if we don't have a file, start at zero +if [ ! -f "/tmp/monitor_mode.dat" ] ; then + monitor_mode="all" +# otherwise read the value from the file +else + monitor_mode=`cat /tmp/monitor_mode.dat` +fi + +if [ $monitor_mode = "all" ]; then + monitor_mode="INTERNAL" + xrandr --output $INTERNAL_OUTPUT --auto + xrandr --output $EXTERNAL_OUTPUT_1 --off + xrandr --output $EXTERNAL_OUTPUT_2 --off + notify-send 'External display OFF' +# elif [ $monitor_mode = "EXTERNAL" ]; then +# monitor_mode="INTERNAL" +# xrandr --output $INTERNAL_OUTPUT --auto +# xrandr --output $EXTERNAL_OUTPUT_1 --off +# xrandr --output $EXTERNAL_OUTPUT_2 --off +# elif [ $monitor_mode = "INTERNAL" ]; then +# monitor_mode="CLONES" +# xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT +else + monitor_mode="all" + xrandr --output $INTERNAL_OUTPUT --auto + xrandr --output $EXTERNAL_OUTPUT_1 --auto --right-of $INTERNAL_OUTPUT + xrandr --output $EXTERNAL_OUTPUT_2 --auto --right-of $EXTERNAL_OUTPUT_1 + ~/.config/polybar/launch.sh + notify-send 'External display ON' +fi + +echo "${monitor_mode}" > /tmp/monitor_mode.dat diff --git a/.config/i3/scripts/wallpapers.sh b/.config/i3/scripts/wallpapers.sh new file mode 100755 index 0000000..ac297af --- /dev/null +++ b/.config/i3/scripts/wallpapers.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +script_name=${BASH_SOURCE[0]} +for pid in $(pidof -x $script_name); do + if [ $pid != $$ ]; then + kill -9 $pid + fi +done + +# source /home/marc/venv/marc/bin/activate + +while true +do + # python /home/marc/Pictures/Pixel/render.py + # feh --bg-center /home/marc/Pictures/Pixel/rendered.bmp + feh --randomize --bg-fill ~/Pictures/Island/extra/*.jpg + sleep 5m +done diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100644 index 0000000..f7df074 --- /dev/null +++ b/.config/nvim/init.vim @@ -0,0 +1,377 @@ +" set the runtime path to include Vundle and initialize +set rtp+=~/.config/nvim/bundle/Vundle.vim +call vundle#begin('~/.config/nvim/bundle') + + +" install with :PluginInstall +" let Vundle manage Vundle, required +Plugin 'gmarik/Vundle.vim' + +"-------------------=== Code/Project navigation ===------------- +Plugin 'scrooloose/nerdtree' " Project and file navigation +Plugin 'Xuyuanp/nerdtree-git-plugin' " NerdTree git functionality +Plugin 'airblade/vim-gitgutter' " Show git changes in gutter +Plugin 'majutsushi/tagbar' " Class/module browser +Plugin 'vim-airline/vim-airline' " Lean & mean status/tabline for vim +Plugin 'vim-airline/vim-airline-themes' " Themes for airline +Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " requires fzf and the_silver_searcher (ag) +Plugin 'junegunn/fzf.vim' +Plugin 'tpope/vim-commentary' " Comment lines +Plugin 'tpope/vim-fugitive' + +"-------------------=== Other ===------------------------------- +Plugin 'jiangmiao/auto-pairs' +Plugin 'flazz/vim-colorschemes' " Colorschemes +Plugin 'chrisbra/Colorizer' " Colorize colornames and codes +Plugin 'guns/xterm-color-table.vim' " Display a color table +Plugin 'dylanaraps/wal.vim' +Plugin 'tpope/vim-surround' +Plugin 'tpope/vim-sensible' +Plugin 'ntpeters/vim-better-whitespace' + +"---------------=== Code completion ===--------------------------- +Plugin 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } + +"-------------------=== Language Support ===-------------------- +" Plugin 'scrooloose/syntastic' +Plugin 'w0rp/ale' + +"---------------------=== Fish ===----------------------------- +Plugin 'dag/vim-fish' + +"-------------------=== Python ===----------------------------- +Plugin 'jmcantrell/vim-virtualenv', { 'for': 'python' } +Plugin 'numirias/semshi', {'do': ':UpdateRemotePlugins'} +Plugin 'davidhalter/jedi-vim', { 'for': 'python' } +Plugin 'zchee/deoplete-jedi', { 'for': 'python' } +Plugin 'fisadev/vim-isort' +" Plugin 'vim-vdebug/vdebug' + +"-------------------=== Cypher ===----------------------------- +Plugin 'neo4j-contrib/cypher-vim-syntax', { 'for': 'cypher' } + +"-------------------=== JSON ===------------------------------- +Plugin 'elzr/vim-json' + +"------------------=== Markdown ===---------------------------- +Plugin 'tpope/vim-markdown' +Plugin 'vim-scripts/SyntaxRange' + +" All of your Plugins must be added before the following line +call vundle#end() " required + + +filetype on +filetype plugin on + + +"===================================================== +"" General settings +"===================================================== +set nocompatible " required +filetype off " required +set hidden +set showtabline=0 +let mapleader=" " + +set encoding=utf-8 +colorscheme zenburn +" set background=dark + +set t_Co=256 " 256 colors +set shell=/bin/bash +set number " show line numbers +set ruler +set ttyfast " terminal acceleration + +set tabstop=4 " 4 whitespaces for tabs visual presentation +set shiftwidth=4 " shift lines by 4 spaces +set expandtab " expand tabs into spaces +set colorcolumn=121 + +set showmatch " shows matching part of bracket pairs (), [], {} + +set nobackup " no backup files +set nowritebackup " only in case you don't want a backup file while editing +set noswapfile " no swap files + + +set scrolloff=20 " let 10 lines before/after cursor during scroll + +set clipboard=unnamedplus " use system clipboard + +set exrc " enable usage of additional .vimrc files from working directory +set secure " prohibit .vimrc files to execute shell, create files, etc... +set nocursorline " shows line under the cursor's line + +set lazyredraw " do not redraw screen in the middle of a macro +set smartcase +set ignorecase +set undofile +set inccommand=nosplit + +"===================================================== +"" Deactivate arrows +"===================================================== + +noremap +noremap +noremap +noremap + +inoremap +inoremap + +"===================================================== +"" Tabs / Buffers settings +"===================================================== +tab sball +set switchbuf=useopen +set laststatus=2 +nmap o +nmap i +nmap b :bprev +nmap f :bnext +nmap q :bp bd # +nnoremap :vertical resize -5 +nnoremap :resize +5 +nnoremap :resize -5 +nnoremap :vertical resize +5 + + +"===================================================== +"" Relative Numbering +"===================================================== +nnoremap :set relativenumber! + + +"===================================================== +"" Search settings +"===================================================== +set hlsearch " highlight search results +" clear search highlight +nnoremap h :nohlsearch +" replace word under cursor +" nnoremap r :%s/\<\>/ + + +"===================================================== +"" Ale +"===================================================== +let g:ale_echo_msg_error_str = 'E' +let g:ale_echo_msg_warning_str = 'W' +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' +let g:ale_sign_column_always = 1 +let g:ale_set_highlights = 0 +let b:ale_warn_about_trailing_whitespace = 1 +let g:ale_emit_conflict_warnings = 1 +let g:ale_completion_enabled = 0 +let g:syntastic_python_pylint_post_args="--max-line-length=120" +let g:ale_linters = { +\ 'python': ['flake8', 'pep8'], +\} +let g:ale_fixers = { +\ '*': ['remove_trailing_lines'], +\ 'python': ['isort', 'autopep8'], +\} +let g:ale_fix_on_save = 0 +let g:ale_list_window_size = 15 +let g:ale_echo_cursor = 1 " workaround for vim bug + +nmap ef :ALEFix +nmap ej :ALENext +nmap ek :ALEPrevious +au FileType python setlocal formatprg=autopep8\ --max-line-length=120\ - " mapped to gq by default + + +"===================================================== +"" AirLine settings +"===================================================== +let g:airline#extensions#tabline#enabled=1 +let g:airline#extensions#tabline#formatter='unique_tail_improved' +let g:airline_theme='zenburn' " set airline theme +let g:airline_powerline_fonts = 1 +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif +" let g:airline_left_sep = '' +" let g:airline_right_sep = '' +" let g:airline_symbols.notexists = '' + + +"===================================================== +"" TagBar settings +"===================================================== +let g:tagbar_autofocus=1 +let g:tagbar_width=42 +map :TagbarToggle +" autocmd BufWinEnter *.py :call tagbar#autoopen(0) +autocmd BufWinLeave *.py :TagbarClose + + +"===================================================== +"" NERDTree settings +"===================================================== +let NERDTreeIgnore = ['\.pyc$', '\.pyo$', '__pycache__$', '\~$'] " Ignore files in NERDTree +let NERDTreeWinSize = 40 +autocmd VimEnter * if !argc() | NERDTree | endif " Load NERDTree only if vim is run without arguments +map :NERDTreeToggle +nmap n :NERDTreeFind +let g:NERDTreeDirArrowExpandable = '▸' +let g:NERDTreeDirArrowCollapsible = '▾' +let NERDTreeShowHidden = 1 +let NERDTreeMinimalUI = 1 + + +"===================================================== +"" GitGutter +"===================================================== +nmap ]h GitGutterNextHunk +nmap [h GitGutterPrevHunk +let g:updatetime = 250 + + +"===================================================== +"" Indent Guides Settings +"===================================================== +set listchars=tab:›\ ,trail:•,extends:#,nbsp:. + + +"===================================================== +"" Window Navigation +"===================================================== +nnoremap h +nnoremap j +nnoremap k +nnoremap l + + +"===================================================== +"" Deoplete +"===================================================== +let g:deoplete#enable_at_startup = 1 +let g:python_host_prog = '/usr/bin/python' +let g:python3_host_prog = '/usr/bin/python3' +let g:deoplete#auto_complete_delay = 0 + + + +"===================================================== +"" Vim Virtualenv +"===================================================== +let g:virtualenv_auto_activate = 1 + + + +"===================================================== +"" FZF +"===================================================== +" +nnoremap f :Files +nnoremap t :Ag +" Search current word +nnoremap w :Ag +let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""' " search in all hidden files but .git +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + + +"===================================================== +"" Auto Pairs +"===================================================== +let g:AutoPairsFlyMode = 0 +let g:AutoPairsShortcutFastWrap = '' + + +""===================================================== +""" WhiteSpace Highlight +""===================================================== +let g:strip_whitespace_on_save=1 + + +""===================================================== +""" iSort +""===================================================== +let g:vim_isort_map = '' +let g:vim_isort_python_version = 'python3' + + + +""===================================================== +""" Colorizer +""===================================================== +let g:colorizer_auto_color = 1 +let g:colorizer_disable_bufleave = 1 +let g:colorizer_skip_comments = 1 +let g:colorizer_colornames = 0 +autocmd BufNewFile,BufRead,BufEnter,BufWinEnter * call timer_start(100, { tid -> execute('ColorHighlight')}) + + + +""===================================================== +""" Semshi +""===================================================== +function MyCustomHighlights() + hi semshiLocal ctermfg=209 guifg=#ff875f + hi semshiGlobal ctermfg=214 guifg=#ffaf00 + hi semshiImported ctermfg=214 guifg=#ffaf00 cterm=bold gui=bold + hi semshiParameter ctermfg=75 guifg=#5fafff + hi semshiParameterUnused ctermfg=117 guifg=#87d7ff cterm=underline gui=underline + hi semshiFree ctermfg=218 guifg=#ffafd7 + hi semshiBuiltin ctermfg=207 guifg=#ff5fff + hi semshiAttribute ctermfg=49 guifg=#00ffaf + hi semshiSelf ctermfg=249 guifg=#b2b2b2 + hi semshiUnresolved ctermfg=226 guifg=#ffff00 cterm=underline gui=underline + hi semshiSelected ctermfg=231 guifg=#ffffff ctermbg=161 guibg=#d7005f + + hi semshiErrorSign ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000 + hi semshiErrorChar ctermfg=231 guifg=#ffffff ctermbg=160 guibg=#d70000 + sign define semshiError text=E> texthl=semshiErrorSign +endfunction + +autocmd FileType python call MyCustomHighlights() +autocmd ColorScheme * call MyCustomHighlights() + + + +"===================================================== +"" Jedi Vim +"===================================================== +let g:jedi#auto_initialization = 1 " disable jedi +let g:jedi#auto_vim_configuration = 1 " disable jedi +let g:jedi#completions_enabled = 0 " disable completions +let g:jedi#goto_definitions_command = "" +let g:jedi#documentation_command = "K" +let g:jedi#goto_command = "d" +let g:jedi#goto_assignments_command = "g" +let g:jedi#usages_command = "u" +let g:jedi#completions_command = "" +let g:jedi#rename_command = "r" +let g:jedi#show_call_signatures = "2" +let g:jedi#popup_on_dot = 0 +let g:jedi#smart_auto_mappings = 0 +let g:jedi#use_tabs_not_buffers = 0 +autocmd BufWinEnter '__doc__' setlocal bufhidden=delete " delete jedi docs + +" Set the background transparent +hi Normal guibg=NONE ctermbg=NONE + + +"===================================================== +"" Others +"===================================================== +" Pretty format XML +com! FormatXML :%!python3 -c "import xml.dom.minidom, sys; print(xml.dom.minidom.parse(sys.stdin).toprettyxml())" +nnoremap = :FormatXML diff --git a/.config/polybar/config b/.config/polybar/config new file mode 100644 index 0000000..64391fc --- /dev/null +++ b/.config/polybar/config @@ -0,0 +1,333 @@ +;========================================================== +; +; +; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ +; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ +; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ +; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ +; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ +; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ +; +; +; To learn more about how to configure Polybar +; go to https://github.com/polybar/polybar +; +; The README contains a lot of information +; +;========================================================== + +[colors] +background = #222 +background-alt = #444 +foreground = #dfdfdf +foreground-alt = #555 +primary = #ffb52a +secondary = #e60053 +alert = #bd2c40 + +################################################################################ +################################################################################ +############ MAINBAR-I3 ############ +################################################################################ +################################################################################ + +[bar/mainbar-i3] +;https://github.com/jaagr/polybar/wiki/Configuration + +monitor = ${env:MONITOR} +;monitor-fallback = HDMI1 +monitor-strict = false +bottom = false +fixed-center = true +width = 100% +height = 20 +;offset-x = 1% +;offset-y = 1% + +background = ${colors.background} +foreground = ${colors.foreground} + +; Background gradient (vertical steps) +; background-[0-9]+ = #aarrggbb + +radius = 0.0 +line-size = 2 +line-color = #000000 + +;border-size = 0 +;border-left-size = 25 +;border-right-size = 25 +;border-top-size = 10 +;border-bottom-size = 25 +border-color = #000000 + +padding-left = 1 +padding-right = 1 + +module-margin-left = 0 +module-margin-right = 0 + +;https://github.com/jaagr/polybar/wiki/Fonts +font-0 = "UbuntuMono Nerd Font Mono:style=Regular:size=10;2" +font-1 = "UbuntuMono Nerd Font:size=16;3" +font-2 = "Font Awesome 5 Free:style=Regular:pixelsize=8;1" +font-3 = "Font Awesome 5 Free:style=Solid:pixelsize=8;1" +font-4 = "Font Awesome 5 Brands:pixelsize=8;1" + +modules-left = i3 spotify1 +modules-center = date +modules-right = xkeyboard wifi pulseaudio battery + +separator = " : " + +tray-position = left +tray-detached = false +tray-maxsize = 20 +tray-background = ${colors.background} +tray-offset-x = 0 +tray-offset-y = 0 +tray-padding = 4 +tray-scale = 1.0 + +; Enable support for inter-process messaging +; See the Messaging wiki page for more details. +enable-ipc = true + +; Fallback click handlers that will be called if +; there's no matching module handler found. +click-left = +click-middle = +click-right = +scroll-up = i3wm-wsnext +scroll-down = i3wm-wsprev +double-click-left = +double-click-middle = +double-click-right = + +; Requires polybar to be built with xcursor support (xcb-util-cursor) +; Possible values are: +; - default : The default pointer as before, can also be an empty string (default) +; - pointer : Typically in the form of a hand +; - ns-resize : Up and down arrows, can be used to indicate scrolling +cursor-click = +cursor-scroll = + +[module/xwindow] +type = internal/xwindow +label = %title:0:30:...% + +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock + +format = + +format-foreground = ${colors.foreground-alt} + +format-prefix = +format-prefix-foreground = ${colors.background} +format-prefix-underline = ${colors.secondary} + +label-layout = %layout% +;label-layout-underline = ${colors.secondary} + +label-indicator-padding = 2 +label-indicator-margin = 1 +label-indicator-background = ${colors.secondary} +label-indicator-underline = ${colors.secondary} + +[module/filesystem] +type = internal/fs +interval = 25 + +mount-0 = / + +label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%% +label-unmounted = %mountpoint% not mounted +label-unmounted-foreground = ${colors.foreground-alt} + +[module/bspwm] +type = internal/bspwm + +label-focused = %index% +label-focused-background = ${colors.background-alt} +label-focused-underline= ${colors.primary} +label-focused-padding = 2 + +label-occupied = %index% +label-occupied-padding = 2 + +label-urgent = %index%! +label-urgent-background = ${colors.alert} +label-urgent-padding = 2 + +label-empty = %index% +label-empty-foreground = ${colors.foreground-alt} +label-empty-padding = 2 + +; Separator in between workspaces +; label-separator = | + +[module/i3] +type = internal/i3 +format = +index-sort = true +wrapping-scroll = false + +; Only show workspaces on the same output as the bar +;pin-workspaces = true + +label-mode-padding = 2 +label-mode-foreground = #000 +label-mode-background = ${colors.primary} + +; focused = Active workspace on focused monitor +label-focused = %index% +label-focused-background = ${colors.background-alt} +label-focused-underline= ${colors.secondary} +label-focused-padding = 2 + +; unfocused = Inactive workspace on any monitor +label-unfocused = %index% +label-unfocused-padding = 2 + +; visible = Active workspace on unfocused monitor +label-visible = %index% +label-visible-background = ${self.label-focused-background} +label-visible-underline = ${colors.primary} +label-visible-padding = ${self.label-focused-padding} + +; urgent = Workspace with urgency hint set +label-urgent = %index% +label-urgent-background = ${colors.alert} +label-urgent-padding = 2 + +[module/xbacklight] +type = internal/xbacklight + +format =