From 147d3d75146af8b8f38ed9bd0b0b6de52f9eca23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Tue, 27 Mar 2018 10:50:45 +0200 Subject: [PATCH] Some fish shell configuration changes --- .gitignore | 2 +- terminal/fish/config.fish | 8 +++++--- terminal/fish/functions/fish_prompt.fish | 2 +- terminal/fish/functions/is_ssh_agent_running.fish | 12 ++++++++++++ terminal/fish/functions/ssh_agent_start.fish | 5 +++++ 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 terminal/fish/functions/is_ssh_agent_running.fish create mode 100644 terminal/fish/functions/ssh_agent_start.fish diff --git a/.gitignore b/.gitignore index c6a866b..4058dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -fish/fishd.* +terminal/fish/fishd.* diff --git a/terminal/fish/config.fish b/terminal/fish/config.fish index 31ed5fb..4eb639c 100755 --- a/terminal/fish/config.fish +++ b/terminal/fish/config.fish @@ -1,8 +1,8 @@ -set -x DOTFILES /Users/thomas/dotfiles +set -x DOTFILES $HOME/dotfiles # The definition of $DOTFILES MUST be the first line of this file # Don't change it! -if test "$SHLVL" -le 1 +if test -z "$FISH_SETUP_PATH" # Homebrew path set -x PATH /usr/local/bin /usr/local/sbin $PATH # Personal scripts @@ -20,4 +20,6 @@ set -x LC_ALL sv_SE.UTF-8 set -x EDITOR vim alias v vim -eval (python3 -m virtualfish) +if not is_ssh_agent_running + ssh_agent_start +end diff --git a/terminal/fish/functions/fish_prompt.fish b/terminal/fish/functions/fish_prompt.fish index 592120d..9514913 100755 --- a/terminal/fish/functions/fish_prompt.fish +++ b/terminal/fish/functions/fish_prompt.fish @@ -6,7 +6,7 @@ function fish_prompt end # Hostname with unique color - set_color (hostname -s | md5 | cut -c-6) + set_color (hostname -s | md5sum | cut -c-6) echo -sn (hostname -s) # A yellow separator diff --git a/terminal/fish/functions/is_ssh_agent_running.fish b/terminal/fish/functions/is_ssh_agent_running.fish new file mode 100644 index 0000000..0131183 --- /dev/null +++ b/terminal/fish/functions/is_ssh_agent_running.fish @@ -0,0 +1,12 @@ +function is_ssh_agent_running + if begin; test -f ~/.ssh/env; and test -z "$SSH_AGENT_PID"; end + source ~/.ssh/env > /dev/null + end + + if test -z "$SSH_AGENT_PID" + return 1 + end + + ps -ef | grep $SSH_AGENT_PID | grep -v grep | grep -q ssh-agent + return $status +end diff --git a/terminal/fish/functions/ssh_agent_start.fish b/terminal/fish/functions/ssh_agent_start.fish new file mode 100644 index 0000000..7ad47cf --- /dev/null +++ b/terminal/fish/functions/ssh_agent_start.fish @@ -0,0 +1,5 @@ +function ssh_agent_start + ssh-agent -c | sed 's/^echo/#echo/' > ~/.ssh/env + chmod 600 ~/.ssh/env + source ~/.ssh/env > /dev/null +end