diff --git a/dotfiles/config/powerline/colorschemes/shell/default.json b/dotfiles/config/powerline/colorschemes/shell/default.json new file mode 100644 index 00000000..a626b493 --- /dev/null +++ b/dotfiles/config/powerline/colorschemes/shell/default.json @@ -0,0 +1,21 @@ +{ + "name": "Default color scheme for shell prompts", + "groups": { + "user": {"fg": "white", "bg": "blue"}, + "hostname": {"fg": "brightyellow", "bg": "mediumorange", "attr": []}, + "jobnum": {"fg": "brightyellow", "bg": "mediumorange", "attr": []}, + "exit_fail": {"fg": "white", "bg": "darkestred", "attr": []}, + "exit_success": {"fg": "white", "bg": "darkestgreen", "attr": []}, + "environment": {"fg": "white", "bg": "darkestgreen", "attr": []}, + "mode": {"fg": "darkestgreen", "bg": "brightgreen", + "attr": ["bold"] }, + "attached_clients": { "fg": "white", "bg": "darkestgreen", "attr": [] } + }, + "mode_translations": { + "vicmd": { + "groups": { + "mode": {"fg": "darkestcyan", "bg": "white", "attr": ["bold"]} + } + } + } +} diff --git a/dotfiles/config/powerline/themes/shell/default.json b/dotfiles/config/powerline/themes/shell/default.json new file mode 100644 index 00000000..37dca829 --- /dev/null +++ b/dotfiles/config/powerline/themes/shell/default.json @@ -0,0 +1,39 @@ +{ + "segments": { + "left": [ + { + "function": "powerline.segments.shell.mode" + }, + { + "function": "powerline.segments.common.net.hostname", + "priority": 10 + }, + { + "function": "powerline.segments.common.env.user", + "priority": 30 + }, + { + "function": "powerline.segments.common.env.virtualenv", + "priority": 50 + }, + { + "function": "powerline.segments.shell.cwd", + "priority": 10 + }, + { + "function": "powerline.segments.shell.jobnum", + "priority": 20 + } + ], + "right": [ + { + "function": "powerline.segments.shell.last_pipe_status", + "priority": 10 + }, + { + "function": "powerline.segments.common.vcs.branch", + "priority": 40 + } + ] + } +} diff --git a/dotfiles/emacs.d b/dotfiles/emacs.d index 1c01f9f1..af175903 160000 --- a/dotfiles/emacs.d +++ b/dotfiles/emacs.d @@ -1 +1 @@ -Subproject commit 1c01f9f1dd642d980f41ec09e9031c5844d2cf3e +Subproject commit af17590330dcf1fa5610dd48e9cbcafe269f28b2 diff --git a/dotfiles/lib/bash/prompt.sh b/dotfiles/lib/bash/prompt.sh index ea369602..e552b76a 100644 --- a/dotfiles/lib/bash/prompt.sh +++ b/dotfiles/lib/bash/prompt.sh @@ -65,7 +65,7 @@ function set_bash_prompt() { ╰─$(command_line_character) " } -export PROMPT_COMMAND=set_bash_prompt +# export PROMPT_COMMAND=set_bash_prompt PS2='(%_) ' @@ -74,3 +74,9 @@ case "$TERM" in export PS1='> ' ;; esac + +function set_powerline_prompt { + source "$(python_module_path powerline)/bindings/bash/powerline.sh" +} + +set_powerline_prompt diff --git a/dotfiles/lib/shellrc/functions.sh b/dotfiles/lib/shellrc/functions.sh index e67bdd47..bcb706ff 100644 --- a/dotfiles/lib/shellrc/functions.sh +++ b/dotfiles/lib/shellrc/functions.sh @@ -89,7 +89,7 @@ function digga() { } function shell_stats() { - history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20 + history 0 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20 } function is_ssh() { @@ -260,3 +260,7 @@ function track_modified { echo "Finding..." find $1 -newer $timestamp_file } + +function python_module_path { + python -c "import os, $1; print(os.path.dirname($1.__file__))" +} diff --git a/dotfiles/lib/zsh/prompt.sh b/dotfiles/lib/zsh/prompt.sh index f80e976e..37a6eb37 100644 --- a/dotfiles/lib/zsh/prompt.sh +++ b/dotfiles/lib/zsh/prompt.sh @@ -132,7 +132,14 @@ prompt_tomorrow_colors # For reasons which are currently beyond me, it is not possible to use # $? in PROMPT which is why the second line is so strangely # constructed. -export PROMPT='⚡ % $(print_with_color "%n" "$USERNAME_COLOR") $(separator "at") $(print_with_color "`hostname -s`" "$HOSTNAME_COLOR") $(separator "in") $(print_with_color "`current_directory`" "$CURRENT_DIRECTORY_COLOR")$(git_prompt_info) +function set_my_prompt { + export PROMPT='⚡ % $(print_with_color "%n" "$USERNAME_COLOR") $(separator "at") $(print_with_color "`hostname -s`" "$HOSTNAME_COLOR") $(separator "in") $(print_with_color "`current_directory`" "$CURRENT_DIRECTORY_COLOR")$(git_prompt_info) $(colored_job_count)%(?.$(print_with_color "$(command_line_character) ❯" $PROMPT_CHAR_SUCCESS).$(print_with_color "$(command_line_character) ❯" $PROMPT_CHAR_ERROR)) ' + export PS2='(%_) ' +} -PS2='(%_) ' +function set_powerline_prompt { + source "$(python_module_path powerline)/bindings/zsh/powerline.zsh" +} + +set_powerline_prompt