Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
c67b0314
Commit
c67b0314
authored
Oct 05, 2015
by
Bruno
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #100 from derekstavis/install-remove-fish-prompt
install: Remove existing fish_prompt by backuping
parents
beca6512
05f3be01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
21 deletions
+44
-21
bin/install
bin/install
+24
-12
pkg/omf/cli/omf.destroy.fish
pkg/omf/cli/omf.destroy.fish
+20
-9
No files found.
bin/install
View file @
c67b0314
...
...
@@ -60,6 +60,27 @@ function fish_version_compatible
return (test $major = $OMF_FISH_MIN_VER[1] -a $minor -ge $OMF_FISH_MIN_VER[2])
end
function backup_file -a file_path
test -e "$file_path"; or return 1
set -l path (dirname $file_path)
set -l file (basename $file_path)
set -l name (echo $file | cut -d. -f1)
set -l timestamp (date +%s)
set -l backup_file "$path/$name.$timestamp.copy"
report progress "Existent $file found at $path"
report progress "↳ Moving to $backup_file"
if not mv "$file_path" $backup_file 2>/dev/null
report error "Aborting: Could not backup $file_path"
end
return 0
end
function install_omf
# Grant repository URL ends with .git
set git_uri (echo $OMF_REPO_URI | sed 's/\.git//').git
...
...
@@ -79,19 +100,10 @@ function install_omf
set fish_config_file "$FISH_CONFIG/config.fish"
if test -e "$fish_config_file"
set -l timestamp (date +%s)
set -l original_fish_config_file "$FISH_CONFIG/config.$timestamp.copy"
backup_file "$FISH_CONFIG/config.fish";
or mkdir -p "$FISH_CONFIG"
report progress "Existent fish config file found at $fish_config_file"
report progress "↳ Moving file to $original_fish_config_file"
if not mv "$fish_config_file" "$original_fish_config_file" 2>/dev/null
report error "Aborting: Could not backup fish config file"
end
else
mkdir -p "$FISH_CONFIG"
end
backup_file "$FISH_CONFIG/functions/fish_prompt.fish"
report progress "Adding startup code to fish config file..."
...
...
pkg/omf/cli/omf.destroy.fish
View file @
c67b0314
function __omf.destroy.restore_backup -a file_path
set -l path (dirname $file_path)
set -l file (basename $file_path)
set -l name (echo $file | cut -d. -f1)
set -l backup_file_path (echo $path/$name.*.copy | tr ' ' '\n' | sort -r | head -1)
if test -e "$backup_file_path"
mv "$backup_file_path" "$path/$file" ^/dev/null
else
rm -f "$path/$file" ^/dev/null
end
end
function omf.destroy -d "Remove Oh My Fish"
echo (omf::dim)"Removing Oh My Fish..."(omf::off)
...
...
@@ -5,16 +18,14 @@ function omf.destroy -d "Remove Oh My Fish"
emit uninstall_$pkg
end
set -l fish_config $XDG_CONFIG_HOME/fish
if test "$fish_config" = "/fish"
set fish_config $HOME/.config/fish
end
set -q XDG_CONFIG_HOME;
or set -l XDG_CONFIG_HOME "$HOME/.config"
set -l
localbackup (find $fish_config -regextype posix-extended -regex '^.*fish/config\.[[:digit:]]+\.copy$' |\
sort -r |head -1)
if test -n $localbackup
mv $localbackup "$fish_config
/config.fish"
end
set -l
fish_config_home $XDG_CONFIG_HOME/fish
set -l fish_prompt_home $fish_config_home/functions
__omf.destroy.restore_backup "$fish_config_home
/config.fish"
__omf.destroy.restore_backup "$fish_prompt_home/fish_prompt.fish"
if test "$OMF_PATH" != "$HOME"
rm -rf "$OMF_PATH"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment