Use pure theme for #fishshell

This commit is contained in:
Colin Powell
2019-07-30 11:01:36 -04:00
parent a37c01cc6e
commit 224697d780
55 changed files with 914 additions and 1321 deletions

View File

@ -0,0 +1,31 @@
[ keybindings ]
# Alt + S
state = \es
# Alt + E
stage = \ee
# Ctrl + E
unstage = \ce
# Alt + C
commit-all = \ec
# Alt + D
pull = \ed
# Alt + P
push = \ep
# Alt + U
upstream = \eu
# Alt + L
logs = \el
# Alt + F
feature = \ef
# Alt + H
hotfix = \eh

View File

@ -0,0 +1,8 @@
# Deactivate the default virtualenv prompt so that we can add our own
set --global --export VIRTUAL_ENV_DISABLE_PROMPT 1
# Whether or not is a fresh session
set --global _pure_fresh_session true
# Register `_pure_prompt_new_line` as an event handler fot `fish_prompt`
functions -q _pure_prompt_new_line

View File

@ -0,0 +1,138 @@
# MIT License
# Copyright (c) 2016 Francisco Lourenço & Daniel Wehner
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -g __done_version 1.8.0
function __done_get_focused_window_id
if type -q lsappinfo
lsappinfo info -only bundleID (lsappinfo front) | cut -d '"' -f4
else if type -q xprop
and test $DISPLAY
xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2
end
end
function __done_is_tmux_window_active
set -q fish_pid; or set -l fish_pid %self
not tmux list-panes -a -F "#{session_attached} #{window_active} #{pane_pid}" | string match -q "1 0 $fish_pid"
end
function __done_is_process_window_focused
# Return false if the window is not focused
if test $__done_initial_window_id != (__done_get_focused_window_id)
return 1
end
# If inside a tmux session, check if the tmux window is focused
if type -q tmux
and test -n "$TMUX"
__done_is_tmux_window_active
return $status
end
return 0
end
# verify that the system has graphical capabilites before initializing
if test -z "$SSH_CLIENT" # not over ssh
and test -n __done_get_focused_window_id # is able to get window id
set -g __done_initial_window_id ''
set -q __done_min_cmd_duration; or set -g __done_min_cmd_duration 5000
set -q __done_exclude; or set -g __done_exclude 'git (?!push|pull)'
function __done_started --on-event fish_preexec
set __done_initial_window_id (__done_get_focused_window_id)
end
function __done_ended --on-event fish_prompt
set -l exit_status $status
# backwards compatibilty for fish < v3.0
set -q cmd_duration; or set -l cmd_duration $CMD_DURATION
if test $cmd_duration
and test $cmd_duration -gt $__done_min_cmd_duration # longer than notify_duration
and not __done_is_process_window_focused # process pane or window not focused
and not string match -qr $__done_exclude $history[1] # don't notify on git commands which might wait external editor
# Store duration of last command
set -l humanized_duration (echo "$cmd_duration" | humanize_duration)
set -l title "Done in $humanized_duration"
set -l wd (pwd | sed "s,^$HOME,~,")
set -l message "$wd/ $history[1]"
set -l sender $__done_initial_window_id
# workarout terminal notifier bug when sending notifications from inside tmux
# https://github.com/julienXX/terminal-notifier/issues/216
if test $TMUX
set sender "tmux"
end
if test $exit_status -ne 0
set title "Failed ($exit_status) after $humanized_duration"
end
if set -q __done_notification_command
eval $__done_notification_command
else if type -q terminal-notifier # https://github.com/julienXX/terminal-notifier
terminal-notifier -message "$message" -title "$title" -sender "$sender" -activate "$__done_initial_window_id"
else if type -q osascript # AppleScript
osascript -e "display notification \"$message\" with title \"$title\""
else if type -q notify-send # Linux notify-send
set -l urgency
if test $exit_status -ne 0
set urgency "--urgency=critical"
end
notify-send $urgency --icon=terminal --app-name=fish "$title" "$message"
else if type -q notify-desktop # Linux notify-desktop
set -l urgency
if test $exit_status -ne 0
set urgency "--urgency=critical"
end
notify-desktop $urgency --icon=terminal --app-name=fish "$title" "$message"
else # anything else
echo -e "\a" # bell sound
end
end
end
end
function __done_uninstall -e done_uninstall
# Erase all __done_* functions
functions -e __done_ended
functions -e __done_started
functions -e __done_get_focused_window_id
functions -e __done_is_tmux_window_active
functions -e __done_is_process_window_focused
# Erase __done variables
set -e __done_version
end

View File

@ -0,0 +1,238 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow
function gitnow -d "Gitnow: Speed up your Git workflow. 🐠" -a xversion
if [ "$xversion" = "-v" ]; or [ "$xversion" = "--version" ]
echo "GitNow version $gitnow_version"
else
__gitnow_manual | command less -r
commandline -f repaint;
end
end
function state -d "Gitnow: Show the working tree status in compact way"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "state"; return; end
command git status -sb
commandline -f repaint;
end
function stage -d "Gitnow: Stage files in current working directory"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "stage"; return; end
set -l len (count $argv)
set -l opts .
if test $len -gt 0
set opts $argv
end
command git add $opts
commandline -f repaint;
end
function unstage -d "Gitnow: Unstage files in current working directory"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "unstage"; return; end
set -l len (count $argv)
set -l opts .
if test $len -gt 0
set opts $argv
end
command git reset $opts
commandline -f repaint;
end
function commit -d "Gitnow: Commit changes to the repository"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "commit"; return; end
set -l len (count $argv)
if test $len -gt 0
command git commit $argv
else
command git commit
end
commandline -f repaint;
end
function commit-all -d "Gitnow: Add and commit all changes to the repository"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "commit-all"; return; end
stage
commit .
end
function pull -d "Gitnow: Pull changes from remote server but saving uncommitted changes"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "pull"; return; end
set -l len (count $argv)
set -l xorigin (__gitnow_current_remote)
set -l xbranch (__gitnow_current_branch_name)
set -l xcmd ""
echo "⚡️ Pulling changes..."
set -l xdefaults --rebase --autostash
if test $len -gt 2
set xcmd $argv
echo "Mode: Manual"
echo "Default flags: $xdefaults"
echo
else
echo "Mode: Auto"
echo "Default flags: $xdefaults"
if test $len -eq 1
set xbranch $argv[1]
end
if test $len -eq 2
set xorigin $argv[1]
set xbranch $argv[2]
end
set xcmd $xorigin $xbranch
set -l xremote_url (command git config --get "remote.$xorigin.url")
echo "Remote URL: $xorigin ($xremote_url)"
echo "Remote branch: $xbranch"
echo
end
command git pull $xcmd $xdefaults
commandline -f repaint;
end
# Git push with --set-upstream
# Shortcut inspired from https://github.com/jamiew/git-friendly
function push -d "Gitnow: Push commit changes to remote repository"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "push"; return; end
set -l opts $argv
set -l xorigin (__gitnow_current_remote)
set -l xbranch (__gitnow_current_branch_name)
echo "🚀 Pushing changes..."
if test (count $opts) -eq 0
set opts $xorigin $xbranch
set -l xremote_url (command git config --get "remote.$xorigin.url")
echo "Mode: Auto"
echo "Remote URL: $xorigin ($xremote_url)"
echo "Remote branch: $xbranch"
else
echo "Mode: Manual"
end
echo
command git push --set-upstream $opts
commandline -f repaint;
end
function upstream -d "Gitnow: Commit all changes and push them to remote server"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "upstream"; return; end
commit-all
push
end
function feature -d "GitNow: Creates a new Gitflow feature branch from current branch" -a xbranch
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "feature"; return; end
__gitnow_gitflow_branch "feature" $xbranch
commandline -f repaint;
end
function hotfix -d "GitNow: Creates a new Gitflow hotfix branch from current branch" -a xbranch
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "hotfix"; return; end
__gitnow_gitflow_branch "hotfix" $xbranch
commandline -f repaint;
end
function bugfix -d "GitNow: Creates a new Gitflow bugfix branch from current branch" -a xbranch
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "bugfix"; return; end
__gitnow_gitflow_branch "bugfix" $xbranch
commandline -f repaint;
end
function release -d "GitNow: Creates a new Gitflow release branch from current branch" -a xbranch
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "release"; return; end
__gitnow_gitflow_branch "release" $xbranch
commandline -f repaint;
end
function move -d "GitNow: Switch from current branch to another but stashing uncommitted changes" -a xupstream -a xbranch
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "move"; return; end
if [ "$xupstream" != "-u" ]; and [ "$xupstream" != "--upstream" ]
set xbranch $xupstream
set xupstream ""
end
if test -n "$xbranch"
if [ "$xupstream" = "-u" ]; or [ "$xupstream" = "--upstream" ]
command git stash
command git fetch (__gitnow_current_remote) $xbranch
command git checkout $xbranch
command git stash pop
else
set -l xfound (__gitnow_check_if_branch_exist $xbranch)
if test $xfound -eq 1
if [ "$xbranch" = (__gitnow_current_branch_name) ]
echo "Branch `$xbranch` is the same like current branch. Nothing to do."
else
command git stash
command git checkout $xbranch
command git stash pop
end
else
echo "Branch `$xbranch` was not found. No possible to switch."
echo "Tip: Use -u (--upstream) flag to fetch a remote branch."
end
end
else
echo "Provide a branch name to move."
end
commandline -f repaint;
end
function logs -d "Gitnow: Shows logs in a fancy way"
if not __gitnow_is_git_repository; __gitnow_msg_not_valid_repository "logs"; return; end
set -l args HEAD
if test -n "$argv"
set args $argv
end
command git log $args --color --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit | command less -r
commandline -f repaint;
end
function github -d "Gitnow: Clone a GitHub repository using SSH"
set -l repo (__gitnow_clone_params $argv)
__gitnow_clone_repo $repo "github"
commandline -f repaint;
end
function bitbucket -d "Gitnow: Clone a Bitbucket Cloud repository using SSH"
set -l repo (__gitnow_clone_params $argv)
__gitnow_clone_repo $repo "bitbucket"
commandline -f repaint;
end

View File

@ -0,0 +1,16 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow
set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
set -q fish_config; or set -g fish_config $XDG_CONFIG_HOME/fish
set -q fish_snippets; or set -g fish_snippets "$fish_config/conf.d"
set -q fish_functions; or set -g fish_functions "$fish_config/functions"
set -q GITNOW_CONFIG_FILE; or set -g GITNOW_CONFIG_FILE ~/.gitnow
set -g gitnow_version 2.1.1
source "$fish_functions/__gitnow_functions.fish"
source "$fish_functions/__gitnow_manual.fish"
source "$fish_functions/__gitnow_config_file.fish"
__gitnow_read_config

View File

@ -0,0 +1,65 @@
set --universal pure_version 2.1.8 # used for bug report
# Base colors
_pure_set_default pure_color_primary (set_color blue)
_pure_set_default pure_color_info (set_color cyan)
_pure_set_default pure_color_mute (set_color brblack)
_pure_set_default pure_color_success (set_color magenta)
_pure_set_default pure_color_normal (set_color normal)
_pure_set_default pure_color_danger (set_color red)
_pure_set_default pure_color_light (set_color white)
_pure_set_default pure_color_warning (set_color yellow)
_pure_set_default pure_color_dark (set_color black)
# Prompt
_pure_set_default pure_symbol_prompt ""
_pure_set_default pure_symbol_reverse_prompt "" # used for VI mode
_pure_set_default pure_color_prompt_on_error $pure_color_danger
_pure_set_default pure_color_prompt_on_success $pure_color_success
# Current Working Directory
_pure_set_default pure_color_current_directory $pure_color_primary
# Git
_pure_set_default pure_symbol_git_unpulled_commits "⇣"
_pure_set_default pure_symbol_git_unpushed_commits "⇡"
_pure_set_default pure_symbol_git_dirty "*"
_pure_set_default pure_color_git_unpulled_commits $pure_color_info
_pure_set_default pure_color_git_unpushed_commits $pure_color_info
_pure_set_default pure_color_git_branch $pure_color_mute
_pure_set_default pure_color_git_dirty $pure_color_mute
# SSH info
_pure_set_default pure_color_ssh_hostname $pure_color_mute
_pure_set_default pure_color_ssh_separator $pure_color_mute
_pure_set_default pure_color_ssh_user_normal $pure_color_mute
_pure_set_default pure_color_ssh_user_root $pure_color_light
# Virtualenv for Pyhon
_pure_set_default pure_color_virtualenv $pure_color_mute
# Print current working directory at the beginning of prompt
# true (default): current directory, git, user@hostname (ssh-only), command duration
# false: user@hostname (ssh-only), current directory, git, command duration
_pure_set_default pure_begin_prompt_with_current_directory true
# Show exit code of last command as a separate prompt character (cf. https://github.com/sindresorhus/pure/wiki#show-exit-code-of-last-command-as-a-separate-prompt-character)
# false - single prompt character, default
# true - separate prompt character
_pure_set_default pure_separate_prompt_on_error false
# Max execution time of a process before its run time is shown when it exits
_pure_set_default pure_threshold_command_duration 5
_pure_set_default pure_color_command_duration $pure_color_warning
# Right Prompt variables
_pure_set_default pure_right_prompt ""
_pure_set_default pure_color_right_prompt $pure_color_normal
# VI mode indicator
# true (default): indicate a non-insert mode by reversing the prompt symbol ()
# false: indicate vi mode with [I], [N], [V]
_pure_set_default pure_reverse_prompt_symbol_in_vimode true
# Title
_pure_set_default pure_symbol_title_bar_separator "—"