diff --git a/fish/functions/fish_prompt.fish b/fish/functions/fish_prompt.fish index 0aa8102..b4ea640 100755 --- a/fish/functions/fish_prompt.fish +++ b/fish/functions/fish_prompt.fish @@ -1,21 +1,3 @@ -set -g __fish_prompt_hostname (hostname|cut -d . -f 1) - -function __fish_prompt_git_branch - set __git_branch (git current-branch ^ /dev/null) - - if test -z $__git_branch - return - else if test $__git_branch = HEAD - set __rev (git log -1 --oneline ^ /dev/null) - if not test -z $__rev - echo -n (git log -1 --oneline | cut -d " " -f 1) - end - else - echo -n $__git_branch - end -end - -#### # Fish prompt # Looks like: user@host in cwd(branch) function fish_prompt @@ -50,7 +32,7 @@ function fish_prompt set_color normal set_color blue - echo -n (hostname) + echo -n (nice_hostname) set_color normal set_color -o black @@ -73,7 +55,7 @@ function fish_prompt # Git branch # - set branch (__fish_prompt_git_branch) + set branch (git_branch) if not test -z $branch echo -n "(" diff --git a/fish/functions/git_branch.fish b/fish/functions/git_branch.fish new file mode 100644 index 0000000..020d41c --- /dev/null +++ b/fish/functions/git_branch.fish @@ -0,0 +1,15 @@ +function git_branch + set __git_branch (git current-branch ^ /dev/null) + + if test -z $__git_branch + return + else if test $__git_branch = HEAD + set __rev (git log -1 --oneline ^ /dev/null) + if not test -z $__rev + echo -n (git log -1 --oneline | cut -d " " -f 1) + end + else + echo -n $__git_branch + end +end + diff --git a/fish/functions/nice_hostname.fish b/fish/functions/nice_hostname.fish new file mode 100644 index 0000000..68a51c5 --- /dev/null +++ b/fish/functions/nice_hostname.fish @@ -0,0 +1,4 @@ +function nice_hostname + hostname | cut -d . -f 1 +end + diff --git a/fish/functions/start_agent.fish b/fish/functions/start_agent.fish index 9457404..6dcda72 100644 --- a/fish/functions/start_agent.fish +++ b/fish/functions/start_agent.fish @@ -4,6 +4,6 @@ function start_agent echo "succeeded" chmod 600 $SSH_ENV . $SSH_ENV > /dev/null - ssh-add + ssh-add "~/.ssh/id_(nice_hostname)" end diff --git a/fish/functions/test_identities.fish b/fish/functions/test_identities.fish index 89c8d33..2e5fae1 100644 --- a/fish/functions/test_identities.fish +++ b/fish/functions/test_identities.fish @@ -1,7 +1,7 @@ function test_identities ssh-add -l | grep "The agent has no identities" > /dev/null if [ $status -eq 0 ] - ssh-add + ssh-add "~/.ssh/id_(nice_hostname)" if [ $status -eq 2 ] start_agent end